|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-11-29 17:36:34
Stefan Slapeta wrote:
> Peter Dimov wrote:
>
>> I'm really not sure what do you mean by "modern" boost requirements.
>
> None of the libraries that have recently been included into boost
> placed their headers in the boost root directory. I don't know
> whether this has become a (formal) requirement but that's what I
> wanted to express.
>>> a) this header should be placed in the bind subdirectory, e.g.
>>> boost/bind/bind.hpp
>>
>> What purpose does that serve? Why not boost/bind/bind/bind.hpp?
>
> It was just an idea how to separate this header from the existing. One
> of many possible.
Currently boost/ appears to contain 98 header files. Bringing this down to
97 wouldn't be much of an improvement.
>>> b) this header should introduce a separate namespace 'bind' or
>>> 'function' to avoid the well-known namespace clashes with
>>> boost::lambda that are _really_ annoying.
>>
>>
>> Again, what purpose would that serve? The only name that bind.hpp
>> "reserves" in boost is 'bind'. Defining a namespace 'bind' still
>> reserves the same name in boost, namely, 'bind', except that user
>> code is now uglier.
>
> Try to include boost/bind.hpp and boost/lambda/bind.hpp at the same
> time (just for matters of uniformity: this is the first time where I don't
> agree that one of those includes is in a subdirectory and the other
> is not!) I've not found any solution for how to use e.g. _1 from
> boost.lambda
> in one function and _1 from boost.bind in another _without_ having to
> qualify these two everytime, which is totally ugly IMO.
You bring up the legitimate problem of bind's _1 clashing with lambda's _1
(when "using namespace boost::lambda" is in effect), but I totally don't see
what this has to do with moving boost::bind to boost::bind::bind.
To answer your specific question, ::_1 selects the Bind placeholder and
boost::lambda::_1 selects Lambda's one; consequently, "using ::_1" is an
using declaration for Bind's _1, and "using boost::lambda::_1" is the using
declaration for its Lambda counterpart. I only tested them on VC 7.1,
though; maybe your compiler doesn't accept them?
>> The original intent has been to make the placeholders globally
>> available. As identifiers that start with an underscore are not
>> allowed at the global namespace, and since defining a variable in a
>> header would cause link errors, the placeholders have been put in an
>> unnamed namespace.
>
> ah ... I understand. IIRC, the _1 from boost.lamba are types and don't
> have these problems therefore.
No, Lambda's placeholders are variables in an unnamed namespace, too. MPL's
placeholders are types. :-)
> This means more or less that I'll never be able to write 'using
> boost::_1', no?
Probably not. You'll use "using namespace boost::placeholders" instead, when
bind is modified to conform a bit more closely to TR1. The problem is that
this breaks existing code. Of course when you have two using directives, one
for Bind and one for Lambda, _1 will once again become ambiguous.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk