[Fwd: boost::bind vs. boost::lambda::bind - bug]

The code below fails to compile on g++ (GCC) 3.4.3:
lambda_bind_test.cxx:9: error: `_1' undeclared (first use this function)
lambda_bind_test.cxx:9: error: (Each undeclared identifier is reported
only once for each function it appears in.)
Commenting the include of boost::bind fixes it. How can the second
header hide types defined in the first header?
Shall I report a bug in trac or reopen this one?:
https://svn.boost.org/trac/boost/ticket/3075
Is there any way in the long run the two libraries could be unified?
All the asio examples use boost::bind? Should developers starting out a
new code base use just one? Which one?
#include

-----Original Message----- From: Chris Hite [mailto:C.Hite@rtsgroup.net]
#include
#include //comment this line out and it compiles int foo(const char*);
void test(){ using namespace boost::lambda; bind(foo,_1); }
You've created a conflict among the placeholders. Both bind and lambda::bind
declare _1. bind declares its placeholders at global scope, but lambda
includes in the lambda namespace.
Either use one or the other or don't use the "using namespace
boost::lambda". What I usually do is alias the lambda namespace for brevity.
#include

You've created a conflict among the placeholders. Both bind and lambda::bind
declare _1. bind declares its placeholders at global scope, but lambda includes in the lambda namespace.
My using the inner namespace shouldn't include the outer namespace unless somewhere in the lambda namespace there's a using ::boost. I would consider that to be namespacing bug. For example using boost::lambda shouldn't put shared_ptr in scope either. Consider the following example code: namespace Boost{ typedef char _1; namespace Lambda{ typedef int _1; //using namespace ::Boost; //very naught. don't do this!!! } } void foo(){ using namespace Boost::Lambda; _1 i; //fine as long as the using line above is commented out } Somewhere in the boost::lambda namespace there is a using namespace boost. I can't find it though.
There has been talk about merging these, but I'm not sure the status is. Of course, with bind becoming part of the standard that may be difficult.
-- Bill --
Thanks Bill. Maybe lambda can use the same placeholders as the standard. After all the placeholders are just zero sized tags. As soon as meta functions are standardized that work on them lambda could probably use them. Chris

AMDG Chris Hite wrote:
You've created a conflict among the placeholders. Both bind and lambda::bind
declare _1. bind declares its placeholders at global scope, but lambda includes in the lambda namespace.
My using the inner namespace shouldn't include the outer namespace unless somewhere in the lambda namespace there's a using ::boost. I would consider that to be namespacing bug. For example using boost::lambda shouldn't put shared_ptr in scope either.
Consider the following example code: namespace Boost{ typedef char _1; namespace Lambda{ typedef int _1; //using namespace ::Boost; //very naught. don't do this!!! } }
void foo(){ using namespace Boost::Lambda; _1 i; //fine as long as the using line above is commented out }
Somewhere in the boost::lambda namespace there is a using namespace boost. I can't find it though.
Boost.Bind includes the placeholders in the global namespace, not in namespace boost. In Christ, Steven Watanabe

Boost.Bind includes the placeholders in the global namespace, not in namespace boost.
In Christ, Steven Watanabe
http://www.boost.org/doc/libs/1_41_0/boost/bind/placeholders.hpp Thanks Steven. _1 is defined in ::<unnamed>. Why would boost declare things outside of the boost namespace?!? Chris
participants (3)
-
Bill Buklis
-
Chris Hite
-
Steven Watanabe