boost::variant - why is “const char*” converted to “bool”?
问题 I have declared a boost::variant which accepts three types: string , bool and int . The following code is showing that my variant accepts const char* and converts it to bool . Is it a normal behavior for boost::variant to accept and convert types not on its list? #include <iostream> #include "boost/variant/variant.hpp" #include "boost/variant/apply_visitor.hpp" using namespace std; using namespace boost; typedef variant<string, bool, int> MyVariant; class TestVariant : public boost::static