Hello, all: I met a strange compile error, this code will reproduce the problem:: #include <boost/lexical_cast.hpp> #include <boost/variant.hpp> #include <iostream> namespace foo { struct bar {}; } std::ostream& operator << (std::ostream& out, foo::bar) { return out << "BAR"; } int main() { boost::lexical_cast<std::string>(foo::bar()); } However, if I just remove that unused include boost.variant, it works:: #include <boost/lexical_cast.hpp> //#include <boost/variant.hpp> #include <iostream> namespace foo { struct bar {}; } std::ostream& operator << (std::ostream& out, foo::bar) { return out << "BAR"; } int main() { boost::lexical_cast<std::string>(foo::bar()); } Another solution is put that "operator<<" in namespace foo:: #include <boost/lexical_cast.hpp> #include <boost/variant.hpp> #include <iostream> namespace foo { struct bar {}; std::ostream& operator << (std::ostream& out, foo::bar) { return out << "BAR"; } } // namespace foo int main() { boost::lexical_cast<std::string>(foo::bar()); } Anyway, what is boost.variant's business here? Won't that fail to compile, or am I missing something? BTW, I'm using boost 1.48.0 and gcc 4.6.2 in Linux 3.2.2. Regards, Tianjiao