Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-10-16 15:34:22


Howard Hinnant wrote:
> Section 3.9.2/1 just as clearly gives union a classification distinct
> from class. <shrug>

It still says that they are classes:

    "-- unions, which are classes capable of containing objects of different
types at different times"

>
> The type traits lib used 3.9 as the guide,

OK, I can understand that.

> and I think a distinction between class and union is useful in practice.

Sure, that's what 'is_union' is for :).

One particular reason why I am raising this question is that a simple and
clean 'is_class' implementation below (based on Paul Mensonides work)
naturally gives you a positive answer on union arguments as well:

// from boost/type_traits/is_class.hpp
template <typename T>
struct is_class_impl
{
    template <class U> static ::boost::type_traits::yes_type
is_class_tester(void(U::*)(void));
    template <class U> static ::boost::type_traits::no_type
is_class_tester(...);

    BOOST_STATIC_CONSTANT(bool, value =
        sizeof(is_class_tester<T>(0)) ==
sizeof(::boost::type_traits::yes_type)
        );
};

We either need to make it conform to our current 'is_class' definition by
explicitly handling that case, or fix the definition.

Aleksey


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