Boost logo

Boost Users :

From: Peng Yu (pengyu.ut_at_[hidden])
Date: 2008-05-29 23:23:25


Hi,

To promote a type, no matter complex or not, to the complex type can
be done by the following code. RET would give me a complex type. The
code is simple. I'm wonder if boost has already supplied such facility
so that I don't have to include the following snippet in my own code.

Thanks,
Peng

#include <complex>
#include <iostream>

template <typename T>
struct convert {
  typedef std::complex<T> RET;
};

template <typename T>
struct convert<std::complex<T> > {
  typedef std::complex<T> RET;
};

int main() {
  std::cout << convert<double>::RET() << std::endl;
  std::cout << convert<std::complex<double> >::RET() << std::endl;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net