30 May
2008
30 May
'08
3:23 a.m.
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; }