Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-12-05 11:45:40


In the following program, I expect i1 and i2 to have the same type. Likewise
ir1 and ir2. Does anyone know what's going on?

#include <boost/type_traits/cv_traits.hpp>
#include <boost/type_traits/transform_traits.hpp>
template <class X> struct undefined;
template <class T> struct constref
{
    typedef T const& type;
};

template <class T> struct constref<T&>
{
    typedef T const& type;
};

template <class T> struct constref2
{
    typedef boost::add_reference<boost::add_const<T>::type>::type type;
};

template <class T> struct constref2<T&>
{
    typedef typename boost::add_const<T>::type t1;
    typedef typename boost::add_reference<t1>::type type;
};

// error messages show types
undefined<constref<int>::type> i;
undefined<constref<int&>::type> ir;
undefined<constref2<int>::type> i2;
undefined<constref2<int&>::type> ir2;

===================================================
  David Abrahams, C++ library designer for hire
 resume: http://users.rcn.com/abrahams/resume.html

        C++ Booster (http://www.boost.org)
          email: david.abrahams_at_[hidden]
===================================================


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk