Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2003-10-01 08:45:33


Neal D. Becker wrote:
> A nice addition to type_traits would be: is_complex.

Seems like a very special case. How about something more generic:

is_template_base< std::complex, T >::value

Although the number of template parameters might be a problem. For 1
parameter, it might look like this:

// Warning: Untested, just spitting out some ideas...

template< template< typename > class T, typename U >
struct is_template_base
{
   struct detail
   {
     static no_type check(...);
     template< typename V >
     static yes_type check(const T<V>&);
     static U f();
   };
   enum {
     value = sizeof(detail::check(detail::f())) == sizeof(yes_type)
   };
};

Obviously we would need versions for more template-parameters, the
preprocessor-lib might help. Comments?

Regards, Daniel

-- 
Daniel Frey
aixigo AG - financial training, research and technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: daniel.frey_at_[hidden], web: http://www.aixigo.de

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