[MPL] is lambda<apply<...> >::type wrong?
[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?
::type doesn't compile at all. This is surprising since for example
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 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
Vladimír Marko writes:
[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?
A bug (implying that "always" == "even when type-list is a placeholder expression"); please see http://thread.gmane.org/gmane.comp.lib.boost.user/9699 for further explanation. HTH, -- Aleksey Gurtovoy MetaCommunications Engineering
participants (2)
-
Aleksey Gurtovoy
-
Vladim�r Marko