On Sun, 23 Feb 2014, Paolo Carlini wrote:
On 02/23/2014 11:32 AM, Marc Glisse wrote:
Hello,
looking at this question:
http://stackoverflow.com/q/21737186/1918193
I was surprised to see that libstdc++'s std::complex basically just works
with user-defined types, even weird expression template ones, although
that's not a supported use afaik.
The only functions that fail seem to be exp and pow, both because they call
polar with two arguments that have different (expression) types.
I am not proposing to make this a supported use, but the cost of this small
patch seems very low, and if it makes a couple users happy...
Regtested with no problem on x86_64-linux-gnu, ok for stage 1?
I would even be in favor of applying it now. Can we figure out simple (ie,
not relying on boost...) testcases too?
I didn't try std::complex<std::valarray<X>>, maybe...
Otherwise, you need a type T with all the (real) math functions defined,
and where every operation returns a different type (implicitly convertible
to T). And then you want to call all the complex functions.
That seems doable, but way bigger than I'm willing to go for this
feature. If you want to take over, be my guest ;-)
--
Marc Glisse