mapbox/variant

cant use bool and string in a variant

mahdy-asady opened this issue · 1 comments

i cant use below code:
variant<int, double, string, bool> a = "Test";

but when i remove bool variable type it works fine!

variant<int, double, string, bool> a = "Test";

is ambiguous, because the compiler has two equally good conversions available:
a) const char* to bool (implicit pointer-to-bool conversion)
b) const char* to std::string (using std::string conversion constructor)

You need to disambiguate it yourself, e.g.:

variant<int, double, string, bool> a = string("Test");