Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-10-03 10:42:33


I was pretty sure I posted something about this, but can't find it,
so...

Yesterday I checked in some changes to is_enum which allow it to work
for a new case on a variety of compilers (everything which supports
SFINAE, plus VC7):

  struct convertible_to_anything
  {
      template<typename T> operator T() { return 0; }
  };

  TT_TEST_BEGIN(is_enum)

  BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_enum<convertible_to_anything>::value, false);

  TT_TEST_END

This case has been checked in as tricky_enum_test.cpp.

In the process, I made a few trivial changes which allow EDG compilers
to use the "conforming" is_class implementation. It was as simple as
introducing a few specializations to strip cv-qualification from the
argument.

I note that this was needed in order to pass the is_class tests
because they expect is_class<SomeClass const>::value to be true. We
don't have similar tests for is_enum.

  a. Should we?

  b. Regardless, is it documented somewhere that const-ness is
     irrelevant to class-ness as far as the traits are concerned?
     Obviously if a == yes, then we need the same for is_enum.

Note also, the is_enum implementation needed a subset of the
is_class_impl functionality, which was duplicated instead of reusing
is_class, in part because it would have kept the is_enum change from
working with vc7. Also, though, is_enum didn't need the elimination
of unions performed by is_class. Some refactoring may be in order here.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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