Hi! Bo Peng wrote:
However, I can not output a variant vector work by defining ostream& operator<< vector<double> . Attached is a test case. Note that variant int, string can be outputed, but not the vector. Yet, cout << vector<double> is working.
The problem is not in the variant itself, but it the function lookup of C++: Your operator << is neither defined in the namespace of the ostream (which is std::) nor defined in the namespace from where it is called (which is boost::). That's why the compiler does not find your function when using the variant. You must not put anything into the std namespace but function overloads AFAIK. So try to put your operator << into the namespace std. You can search throu the newsgroup comp.lang.cpp.moderated for further information. Frank