Boost logo

Boost :

From: Kevin S. Van Horn (Kevin.VanHorn_at_[hidden])
Date: 2002-10-14 09:47:39


I've been looking over some of the type traits stuff, and I had a question
about the implementation of is_enum. Here is the code in question:

template <typename T> struct is_enum
{
private:
   typedef ::boost::add_reference<T> ar_t;
   typedef typename ar_t::type r_type;
       
   BOOST_STATIC_CONSTANT(bool, selector =
      (::boost::type_traits::ice_or<
           ::boost::is_arithmetic<T>::value
         , ::boost::is_reference<T>::value
       // We MUST do this on conforming compilers in order to
       // correctly deduce that noncopyable types are not enums (dwa
       // 2002/04/15)...
         , ::boost::is_class<T>::value
>::value));
    typedef ::boost::detail::is_enum_helper<selector> se_t;
    typedef typename se_t::template type<r_type> helper;
public:
    BOOST_STATIC_CONSTANT(bool, value = helper::value);
};

I'm quite mystified by the comment about ORing is_class<T>::value into
selector. How is the fact that a class C is noncopyable going to make
is_enum_helper<false>::type<r_type>::value true? I tried to look up the
mentioned message in the mailing list archives, and it didn't shed any
light.


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