Given the following class:
struct foo : public boost::static_visitor<> {
void do_stuff(int item) {}
}
Now, in another context I have an std::vector<foo>
and want to execute the following algorithm on it:
using namespace std::tr1;
using namespace std::tr1::placeholders;
std::vector<foo> items;
std::for_each(items.begin(), items.end(), bind(&foo::do_stuff, _1));
This throws a huge template error message, that boils down to an ambiguous call to std::tr1::ref
or boost::ref
. If I remove the base-class boost::static_visitor
from foo
everything works fine.
As far as I understand it, the problem is that deep down in the code of std::tr1::bind
, a ref(arg)
is called without namespace qualification. Because bind
is in the namespace std::tr1
, std::tr1::ref
is in scope. But, because foo
inherits from a class that is in the namespace boost
, ADL also finds boost::ref
. Is that understanding correct?
Since I need that base-class (it is part of Boost.Variant), I need to know if tis here any way to disambiguate this call from my code?
Note: I am stuck with C++03 here, hence the use of std::tr1
.