Boost logo

Boost Users :

From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2007-07-26 06:53:42


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


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