Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-01-20 19:50:19


I recently ran into this problem when using ob_type_traits #1, but I can see
that type_traits #2 is going to have the same issue:

Some of the templates declare static members whose type is the same as their
type parameters. This makes them unusable when the type parameter is void.
IOW,

   static T x;

is illegal in any context if T is void. The solution, which I'm working out
in type_traits #1 (at least for is_same), is to use:

   static boost::type<T> x;

You can find boost::type<T> in boost/type.hpp, which is checked into CVS.

Another problem I found when I was doing this was that you take sizeof(T),
which is also rejected by MSVC when T is void. Using
detail::size_of<T>::value, defined this way

   template <class T>
   struct size_of
   {
       enum { value = sizeof(T) };
   };

   template <>
   struct size_of<void>
   {
       enum { value = 0 };
   };

Seems to solve the problem. I wonder if we should expose detail::size_of as
boost::size_of?

-Dave


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