Boost logo

Boost Users :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2006-03-01 10:56:07

Lucio Flores writes:
> So as an exercise, I'm trying to use a lambda expression that
> applies the first argument twice on it's second argument.
> typedef mpl::apply<_1, mpl::apply<_1, _2>::type>::type twice_type;

I'm afraid this doesn't do what you think. Following a metafunction
with '::type' means invoking it, so the above is basically equivalent

    typedef mpl::apply<_1, _2>::type t;
        // == _1::apply<_2>::type == _2
    typedef mpl::apply<_1,t>::type twice_type;
        // == _1::apply<t>::type == _1::apply<_2>::type
        // == _2

> Then I instance this lambda function on boost::add_pointer and int
> typedef mpl::apply<twice_type, boost::add_pointer<_1>, int>::type result_type;

.. and, in its turn, this is equivalent to

   typedef mpl::apply<_2, boost::add_pointer<_1>, int>::type result_type;

which gives you the result you refer to below.

> But using boost::is_same, I've found that result_type==int, not
> int** as expected. Can someone see why?


Aleksey Gurtovoy
MetaCommunications Engineering

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at