C99 _Complex and C++ complex<> interoperability.
Gabriel Dos Reis
gdr@cs.tamu.edu
Mon Feb 26 01:21:00 GMT 2007
"Smith-Rowland, Edward M" <ESmith-rowland@alionscience.com> writes:
| All,
|
| This message is probably a combination of C++ standards (OT), gcc
| implementation, and gcc-help so apologies in advance.
|
| In discussions on the GSL mailing list about special functions and other
| numerical issues, complaints about the lack of interoperability of C++
| complex and C99 complex came up. I'm trying to hunt down information on
| these issues.
|
| I have noticed that it is possible (since 4.0) to construct and assign
| from a C99 complex number to a C++ complex number.
|
| I think this is very cool. This goes part way towards reconciling C99
| and C++ as far as complex numbers are concerned.
|
| I don't see this in the C++ standard or under g++ extensions in the
| manual.
It is not in the ISO C++ standard. It is purely a libstdc++
implementation detail. However, I've taken deliberately chosen to
make ISO C++ std::complex<> and ISO C _Complex interoperate where
possible. It is therefore a GCC extension that I'm not willing to
formally document at this moment because there are other issues that
are resolved yet and that might change in the future.
| My questions are:
| Is this behavior standard or is this a gcc extension?
| If this is a gcc extension where is it documented?
|
| Also, if this behavior is nonstandard is anyone thinking about
| standardizing it?
I don't see howw standardize something ISO C++ consciously chosed to
ignore. Certainly, I'm not going to champion it.
| Finally, the circle would be complete if we could assign from
| std::complex to _Complex.
| Any ideas?
You can cast a std::complex<T> to a T _Complex*. Yes, it is ugly.
But it is a guarantee.
-- Gaby
More information about the Libstdc++
mailing list