Boost 1_31 - Problem with Lambda, UnNamed namespaces VC7.1

I have searched the list archive and have not found anything on this subject. I have what looks like to be an issue with MSVC7.1 and unnamed namespaces (the _1 _2 and _3 are in unnamed namespaces in boost::lambda) See below: #include <boost/bind.hpp> #include <boost/Lambda/lambda.hpp> // adding my code to the boost::lambda namespace // below works fine namespace boost { namespace lambda { void MyFunction() { using namespace std; list<int> v; v.push_back(1); v.push_back(2); v.push_back(3); v.push_back(4); v.push_back(5); // Line below works for_each(v.begin(), v.end(), std::cout << _1 << ' '); } } } // Now global namespace void MyFunction() { using namespace std; using namespace boost; using namespace boost::lambda; list<int> v; v.push_back(1); v.push_back(2); v.push_back(3); v.push_back(4); v.push_back(5); // Line below fails with a "error C2872: '_1' : ambiguous symbol" for_each(v.begin(), v.end(), std::cout << _1 << ' '); // This line DOES work for_each(v.begin(), v.end(), std::cout << boost::lambda::_1 << ' '); } Has anyone else run into this? Also- I do not have the current CVS tree handy (I am using 1.31), is this a problem on 1.32? If it is workedaround in some fashion, I can just qualify every _1 and _2 until 1.32 comes out. Thanks for any help or suggestions Brian Braatz

"Brian Braatz" <brianb@rmtg.com> writes:
I have searched the list archive and have not found anything on this subject.
I have what looks like to be an issue with MSVC7.1 and unnamed namespaces (the _1 _2 and _3 are in unnamed namespaces in boost::lambda)
Don't you mean in Boost.Bind? -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

On Sat, 9 Oct 2004 13:59:49 -0600, Brian Braatz <brianb@rmtg.com> wrote:
I have searched the list archive and have not found anything on this subject.
I have what looks like to be an issue with MSVC7.1 and unnamed namespaces (the _1 _2 and _3 are in unnamed namespaces in boost::lambda)
I think you'll find the issue is that you've got #include's for bind and lambda, both of which inject argument placeholders (_1 etc) into the root namespace - both Boost.Bind and Boost.Lambda give you function binders (see http://www.boost.org/libs/lambda/doc/ar01s08.html#id2828068). Remove the include of bind.hpp and you're sorted. Stuart Dootson

Stuart Dootson <stuart.dootson@gmail.com> writes:
On Sat, 9 Oct 2004 13:59:49 -0600, Brian Braatz <brianb@rmtg.com> wrote:
I have searched the list archive and have not found anything on this subject.
I have what looks like to be an issue with MSVC7.1 and unnamed namespaces (the _1 _2 and _3 are in unnamed namespaces in boost::lambda)
I think you'll find the issue is that you've got #include's for bind and lambda, both of which inject argument placeholders (_1 etc) into the root namespace - both Boost.Bind and Boost.Lambda give you function binders (see http://www.boost.org/libs/lambda/doc/ar01s08.html#id2828068). Remove the include of bind.hpp and you're sorted.
That will fix the problem, but IIRC you have the cause wrong. Boost.Bind puts its placeholders into an unnamed namespace at the top level. Lambda puts them in boost::lambda, but there's a using-directive for boost::lambda there in the OP's code. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

On Sun, 10 Oct 2004 07:35:03 -0400, David Abrahams <dave@boost-consulting.com> wrote:
That will fix the problem, but IIRC you have the cause wrong.
Boost.Bind puts its placeholders into an unnamed namespace at the top level. Lambda puts them in boost::lambda, but there's a using-directive for boost::lambda there in the OP's code.
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com
True - missed that one - I've more experience with Bind than BLL as VC6 is my everyday compiler :-( Stuart Dootson

Brian Braatz wrote:
Also- I do not have the current CVS tree handy (I am using 1.31), is this a problem on 1.32? If it is workedaround in some fashion, I can just qualify every _1 and _2 until 1.32 comes out.
It will still be a problem in 1.32, although I'm planning to fix it for 1.33.
participants (4)
-
Brian Braatz
-
David Abrahams
-
Peter Dimov
-
Stuart Dootson