Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-11-30 09:09:14

David Abrahams wrote:
> Peter Dimov wrote:
>> David Abrahams wrote:
>>> Peter Dimov wrote:
>>>> (I had boost::placeholders in mind for a
>>>> namespace, consistent with std::tr1::placeholders; when you use
>>>> 'boost' as a substitute for 'std::tr1', boost::bind::placeholders
>>>> won't work.)
>>> Okay, as long as you cooperate with phoenix and lambda, as far as
>>> I'm concerned.
>> What specific kind of cooperation do you have in mind?
> Ideally? You all use the same placeholders.

Ideally, yes.

In practice, this can't happen, not with the current implementations of Bind
and Lambda. I don't know about Phoenix, but it doesn't use _1 anyway.

The problem on Boost.Bind's side is that it recognizes placeholders by their
exact type, rather than using an is_placeholder metafunction, as specified
in TR1. So it can only work with its own placeholders.

The problem on Lambda's side is that Lambda's placeholders aren't really
placeholders, but full-featured Lambda functors. Lambda doesn't use an
is_placeholder metafunction either.

In principle, Bind can use Lambda functors as placeholders, but getting
around the ODR problem would require Borland's version of placeholders
(inline functions named _k) to be used on all compilers in Bind, and such an
inline function can't be a Lambda functor.

In addition, Bind's placeholders are assignable. This allows Bind's function
objects to be assignable as well. In Lambda, _1 = _1 is not an assignment,
but a lambda expression.

The framework outlined in TR1 - is_placeholder and is_bind_expression -
allows two implementations of tr1::bind to recognize each other's
placeholders and subexpressions, so that you can mix and match lib1::bind,
lib2::bind, lib1::_1 and lib2::_2 in the same bind expression.
Unfortunately, neither Boost.Bind nor Boost.Lambda honor this framework, and
there are objective reasons for both to not change to accommodate it. (In
Bind's case, support for older compilers.)

Boost list run by bdawes at, gregod at, cpdaniel at, john at