I suspect you are missing cases on your do_compare static_visitor. Remeber, the variants might have anything, so you need all possible combinations, like comparing a FooList::const_iterator to a FooMap::const_iterator. It's complaining because the compiler is trying to find some match for that case, and can't convert a FooMap::const_iterator to a FooList::const_iterator.
Hammering it out:
struct do_compare : boost::static_visitor<bool>
{
bool operator() (
const FooMap::const_iterator & a,
const FooMap::const_iterator & b) const
{ return a != b; }
bool operator() (
const FooList::const_iterator & a,
const FooList::const_iterator & b) const
{ return a != b; }
bool operator() (
const FooMap::const_iterator & a,
const FooList::const_iterator & b) const
{ return false; }
bool operator() (
const FooList::const_iterator & a,
const FooMap::const_iterator & b) const
{ return false; }
};
Here's a version with templates:
template <typename A, typename B>
bool operator() (
const A & a,
const B & b) const
{ return false; }
template <typename A>
bool operator() (
const A & a,
const A & b) const
{ return a != b; }
It's compiling on comeau, but I'm not 100% it will work, so some testing is required. Other than cleaner, more versatile code, it shouldn't have any effect, as long as it works.
Todd Gardner
2009-06-09 14:47:44