Boost logo

Boost :

From: Neal Becker (ndbecker2_at_[hidden])
Date: 2005-10-07 06:53:56


SourceForge.net wrote:

> Bugs item #1315712, was opened at 2005-10-07 10:03
> Message generated for change (Tracker Item Submitted) made by Item
> Submitter You can respond by visiting:
>
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1315712&group_id=7586
>
> Please note that this message will contain a full copy of the comment
> thread, including the initial issue submission, for this request,
> not just the latest update.
> Category: type_traits
> Group: None
> Status: Open
> Resolution: None
> Priority: 5
> Submitted By: Edward Grace (ejgrace)
> Assigned to: John Maddock (johnmaddock)
> Summary: Adding boost::is_complex to type_traits.hpp
>
> Initial Comment:
> Following a discussion on boost-users I am adding this
> to the bug system so it doesn't get lost.
>
> Can someone add a boost::is_complex<T> trait so that
> checks for complex numbers can be made. This is a
> common requirement in templated scientific code as
> complex numbers sometimes need to be treated differently.
>
> Attached is my implementation, please feel free to
> incorperate it.
>

Uh, where is it?

There are a number of useful things to go with complex. Here is another.

It is common to need the scalar type that corresponds to a numeric type,
whether that type is complex or scalar. For example, the type returned by
abs. Implementation is pretty trivial:

#include <complex>

template<typename T>
struct Scalar {
  typedef T type;
};

template<typename T>
struct Scalar<std::complex<T> > {
  typedef T type;
};


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