Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2007-04-27 18:48:48


Peter Dimov wrote:
> Daniel Walker wrote:
>
> [...]
>
>> _1 == _2 // ambiguous
>> lambda::hold(_1) == _2 // lambda expression
>> lambda::release(_1) == _2 // 3rd-party expression
>
> I think that the right thing here (if we take the interoperability issue to
> heart) is to make
>
> _1 == _2
>
> "just work". It's an interesting challenge, but it's not impossible since
> that is exactly what is_bind_expression is intended to solve.
>
> The next milestone, boost::bind( f, _1 + _2 ), is harder since it requires
> boost::bind to respect specializations of is_bind_expression.

Although I don't know all the details of bind and lambda, I had hoped
that _1 and _2 would be abstract proto entities, such that

    _1 == _2

creates an expression template like:

    equal< terminal< arg<1> >, terminal< arg<2> > >

which is a generic, abstract representation of an equals expression with
two placeholders. Can't bind and lambda both be implemented to recognize
such a type and do the appropriate thing with it?

The only minor complication is that for the placeholders and expressions
containing them, operator() must evaluate the expression rather than
create a larger expression template. But that's trivial to do with proto.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk