Beware: This is GCC 4.1.2. We're on a proprietary embedded platform. We cannot update to a new compiler. So C++03 + TR1 it is.
We somewhere have a function like this:
template<typename T>
void foo(const boost::any& x)
{
bar(boost::any_cast<T>(x));
}
which is then later used in a bind expression:
std::tr1::bind( &foo<T>, _1);
This generates the following error:
error: call of overloaded 'ref(const boost::any&)' is ambiguous
note: candidates are: std::tr1::reference_wrapper<_Tp> std::tr1::ref(_Tp&) [with _Tp = const boost::any]
note: const boost::reference_wrapper boost::ref(T&) [with T = const boost::any]
I do understand that this is Koenig lookup hitting us. However, I lack ideas about how to circumvent this problem.
Anyone out there?
ref
in your code intentional? – Grosgrainref
? – Archibaldref
, whereas the error does. I was asking whether that is intentional or not. By your mention of ADL I wasn't sure. – Grosgrainstd::tr1::bind
that an unqualified call toref()
is made with aboost::any
as a parameter. Koenig lookup seems to makeboost::ref()
just as good a match asstd::tr1::ref()
for this call. Hence the error. Anyway, Dietmar's nice idea employing a special overload solved this. – Archibaldref()
. If it usesref()
it should really qualify it. – Bourke