typedef boost::variant<long long,double,string> possibleTypes ;
set<possibleTypes,less<possibleTypes> > ascSet ;
set<possibleTypes,greater<possibleTypes> > descSet ;
When I try to compile I get a bunch of errors in some library headers.
But, if I remove the third line (the one with descSet
) the code compile just fine.
What's the problem? Can't boost::variant objects be sorted in descendant order??
Edit:
I'm using Visual Studio 2005 and Boost 1.38.0 and the following command line:
cl /EHsc /I"C:\boost_1_38_0" test.cpp
Edit2 As it was suggested, by Doug T, if I define this:
bool operator>(const possibleTypes& a, const possibleTypes& b){
return b < a ;
}
Then the following code doesn't compile:
possibleTypes pt1="a", pt2="b" ;
greater<possibleTypes> func ;
cout << func(pt1,pt2) << endl ;
However, this code compiles just fine:
possibleTypes pt1="a", pt2="b" ;
cout << (pt1 > pt2) << endl ;
Could anyone help me to understand why??
I tried with VC++ 2005 and GCC 3.4.6