Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-10-14 09:53:53

"Kevin S. Van Horn" <Kevin.VanHorn_at_[hidden]> writes:

> 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?

It doesn't help make anything true. It makes sure that the return
value is taken from


In the case where T is a class type. Otherwise,


gets instantiated, which is only legal if T is copyable.

> I tried to look up the mentioned message

Message? Mentioned where?

> in the mailing list archives, and it didn't shed any
> light.

           David Abrahams * Boost Consulting
dave_at_[hidden] *

Boost list run by bdawes at, gregod at, cpdaniel at, john at