|
Boost : |
From: Michael Marcin (mike.marcin_at_[hidden])
Date: 2008-08-20 16:21:04
My environment is VC9 SP1 and Boost 1.35. This problem also occurs in
boost 1.36.
I had some code using lambda which worked fine for several weeks until
today when someone else included my header in his code which used bind.
He told me my code was broken but my tests ran fine. It took us a few
minutes to find the problem and I've distilled it to this trivial
reproducible case.
#include <boost/bind.hpp>
#include <boost/lambda/bind.hpp>
void foo( int )
{
}
int main()
{
using namespace boost::lambda;
bind( &foo, _1 );
}
Compiling this gives:
error C2872: '_1' : ambiguous symbol
1> could be
'c:\vfx\third_party\boost\1_35_0\boost\lambda\core.hpp(69) :
boost::lambda::placeholder1_type &boost::lambda::`anonymous-namespace'::_1'
1> or
'c:\vfx\third_party\boost\1_35_0\boost\bind\placeholders.hpp(42) :
boost::arg<I> `anonymous-namespace'::_1'
1> with
1> [
1> I=1
1> ]
I can make the problem go away by changing main to
int main()
{
using boost::lambda::_1;
using boost::lambda::bind;
bind( &foo, _1 );
}
but the actual code uses a lot more lambda and the amount of using
directives I would need makes the code longer than rolling my own functor.
I could also alias lambda to make main look something like
int main()
{
namespace bll = boost::lambda;
bll::bind( &foo, bll::_1 );
}
but this introduces a lot of noise into the lambda expression and makes
complex lambdas unreadable.
Is this accepted behavior?
Thanks,
Michael Marcin
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk