Boost logo

Boost Users :

From: Vladimír Marko (vmarko_at_[hidden])
Date: 2005-04-29 08:54:42


[using boost 1.32.0 with gcc 3.4.2 (mingw)]

It seems to me that
  is_same<
    lambda<apply<type-list> >::type,
    apply<type-list>
>::type::value
is allways true. Is this intended or a bug?

The exercise 1-6 in the MPL tutorial,
  http://www.boost.org/libs/mpl/doc/tutorial/exercises.html ,
reads
  "Build a lambda expression that has functionality equivalent
  to twice. Hint: mpl::apply is a metafunction!"
where twice is defined as
  template <typename F,typename X>
  struct twice : apply<F,typename apply<F,X>::type> { };
and I think the obvious solution should be
  apply<_1,apply<_1,_2> > .
The problem is that the expression
  apply<
    apply<_1,apply<_1,_2> >,
    add_pointer<_1>,int
>::type
doesn't compile at all. This is surprising since for example
the expression
  apply<
    twice<_1,twice<_1,_2> >,
    add_pointer<_1>,int
>::type
yields int**** as expected. Is there some fundamental
difference between the metafunctions twice and apply?

My tests suggest that the compilation failure is caused
by the property of lambda<apply<...> >::type described
at the top. This seems pretty odd to me since
  lambda<T>::type
is supposed to have a nested template class "apply"
if T is a placeholder-expression and
  lambda<apply<type-list> >::type::apply
refers to the boost::mpl::apply even if the type-list
contains a placeholder-expression (making the whole
apply<type-list> a placeholder-expression). Did I miss
something?

Thanks,
Vladimir Marko


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net