Boost logo

Boost :

From: Neal D. Becker (nbecker_at_[hidden])
Date: 2003-10-01 11:00:59


On Wednesday 01 October 2003 09:45 am, Daniel Frey wrote:
> 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?
>

I am just achieving rank of novice with this template stuff, so I'm afraid I
don't entirely understand the above. But, ignoring the details for a moment,
I don't understand the premise.

Why do you say "Seems like a very special case"?

I would have thought that, if complex is to be supported as an (almost)
first-class type, then is_complex is just as fundamental as is_integral, for
example. The need for it is clear in my work, at least.

I expect is_complex<T> to be true if T is of type std::complex<F> for any type
F. I suppose we could discuss other representations of a complex data type,
is that what you mean by more general? I would have no idea how to address
that question.


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