Compare two variant with boost static_visitor
- by Zozzzzz
I started to use the boost library a few days ago so my question is maybe trivial.
I want to compare two same type variants with a static_visitor. I tried the following, but it don't want to compile.
struct compare:public boost::static_visitor<bool>
{
bool operator()(int& a, int& b) const
{
return a<b;
}
bool operator()(double& a, double& b) const
{
return a<b;
}
};
int main()
{
boost::variant<double, int > v1, v2;
v1 = 3.14;
v2 = 5.25;
compare vis;
bool b = boost::apply_visitor(vis, v1,v2);
cout<<b;
return 0;
}
Thank you for any help or suggestion!