I want to convert value of std::variant to std::string, but this code doesn't work:
using AnyType = std::variant <bool, char, integer, double, std::string, std::vector <AnyType>/*, Object, Extern, InFile*/>;
struct AnyGet {
AnyGet() {}
std::string operator()(std::string& result, const bool& _ctx) { return _ctx ? "true" : "false"; }
std::string operator()(std::string& result, const char& _ctx) { return std::string(1, _ctx); }
std::string operator()(std::string& result, const integer& _ctx) { return std::to_string(_ctx); }
std::string operator()(std::string& result, const double& _ctx) { return std::to_string(_ctx); }
std::string operator()(std::string& result, const std::string& _ctx) { return _ctx; }
std::string operator()(const std::vector <AnyType>& _ctx, const std::string& _nl = "\n") {/*This depends on to_string*/}
};
std::string to_string(const AnyType& _input, const std::string& _new_line){
std::visit(/*I don't know, what I must write here*/);
}
I want to convert, for example, this: (in code) AnyType some = true; to (in console) true.
So, can somebody help me with this?