Hello !

 

I have been trying to work with the MPL but I have some problems with the composition and argument binding concepts.

 

1/ Here is a problem I cannot find a solution for:

I would like to have a placeholder expression (S) which takes a single argument which is itself a placeholder expression of 2 arguments (A).

I want S when invoked with mpl::apply to return a lambda expression (B) of 1 argument which when invoked on (x) would yield the same result than applying the pair (x, x) to (A).

This means I expect apply<S, A> == B and apply<B, x> == apply<A, x, x>.

Could someone tell me if this is possible? (I know how to do this without a placeholder expression for (S) but I would like to improve my understanding of them)

 

Typedef int_<1> one;

Typedef plus<_1, _2> A;

Typedef … S;

Typedef typename apply<S, A>::type B;

BOOST_STATIC_ASSERT(apply<B, one>::type::value == apply<A, one, one>::type::value)

 

 

2/ Why doesn’t bind take a placeholder expression ? If I want to remap a placeholder expression, I can do for example:

 

bind<typename lambda<plus<_1, _2>::type, _1, _1> but why doesn’t the library invoke lambda by itself ?

(bind< plus<_1, _2>, _1, _1> wont work)

 

Is the combination bind/lambda the only way to remap placeholder expressions?

 

 

3/ What is the use of protect? Where can I find some examples?

 

 

Thanks in advance,

 

Charles