[mpl] BOOST_MPL_AUX_LAMBDA_SUPPORT for classes without nested ::type

Hello, The following program does compile fine on a conformant compiler: #include <boost/mpl/apply.hpp> #include <boost/mpl/aux_/lambda_support.hpp> #include <boost/mpl/assert.hpp> #include <boost/type_traits/is_same.hpp> using namespace boost; using namespace boost::mpl; template<typename T> struct foo { BOOST_MPL_AUX_LAMBDA_SUPPORT(1,foo,(T)) }; template<typename T> struct bar { typedef T type; BOOST_MPL_AUX_LAMBDA_SUPPORT(1,bar,(T)) }; typedef apply1<foo<_1>,int>::type t1; typedef apply1<bar<_1>,int>::type t2; BOOST_MPL_ASSERT((is_same<t1,foo<int> >)); BOOST_MPL_ASSERT((is_same<t2,int>)); int main(){return 0;} Note that foo<_1> applied to int resolves to foo<int> whereas bar<_1> resolves to int, which is correct because the former class does not have a nested ::type while the latter does. This is documented in the MPL reference at: http://www.boost.org/libs/mpl/doc/refmanual/quote.html Now, if I compile the same program with a defective compiler (MSVC 6.0) not supporting PTS, I've got the following: ...\boost\boost\mpl\aux_\preprocessed\msvc60\apply_wrap.hpp(77) : error C2039: 'type' : is not a member of 'result_<int>' ...\boost\mpl\aux_\preprocessed\msvc60\bind.hpp(184) : see reference to class template instantiation 'boost::mpl::apply_wrap1<class foo_rebind,int>' being compiled whereas the code associated with bar<> works OK. So, it seems like BOOST_MPL_AUX_LAMBDA_SUPPORT does not provide lambda support for classes without nested ::type: 1. Is this so by design and/or documented somewhere? 2. If not, could it be fixed? Thank you, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

on Thu Jul 26 2007, Joaquín Mª López Muñoz <joaquin-AT-tid.es> wrote:
whereas the code associated with bar<> works OK. So, it seems like BOOST_MPL_AUX_LAMBDA_SUPPORT does not provide lambda support for classes without nested ::type:
Right.
1. Is this so by design
Sorta. Support for classes without nested type is a convenience for people who need to generate foo<T> where foo is a 3rd-party template on which one can't intrude, so they don't need to write a make_foo<T> metafunction that produces foo<T>. Presumably if you can intrude on the class to add BOOST_MPL_AUX_LAMBDA_SUPPORT, you can also intrude to add a nested ::type.
and/or documented somewhere?
Probably not.
2. If not, could it be fixed?
I don't know; if you come up with a fix that doesn't break anything else, I'd encourage Aleksey to at least consider it. I don't consider it a high enough priority to search for a fix myself. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com The Astoria Seminar ==> http://www.astoriaseminar.com
participants (2)
-
David Abrahams
-
Joaquín Mª López Muñoz