* C99 _Complex and C++ complex<> interoperability.
@ 2007-02-21 22:00 Smith-Rowland, Edward M
0 siblings, 0 replies; only message in thread
From: Smith-Rowland, Edward M @ 2007-02-21 22:00 UTC (permalink / raw)
To: gcc-help
All,
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.
My questions are:
Is this behavior standard or is this a gcc extension?
If this is a gcc extension where is it documented?
Thank you.
----------------------------------------------------------
#include <complex>
int main(int, char**)
{
std::complex<float> jf(0.0F, 1.0F);
std::complex<double> jd(0.0, 1.0);
std::complex<long double> jl(0.0L, 1.0L);
float _Complex jcf;
double __complex__ jcd;
long double _Complex jcl;
std::complex<float> zff(jcf);
std::complex<float> zfd(jcd);
std::complex<float> zfl(jcl);
std::complex<double> zdf(jcf);
std::complex<double> zdd(jcd);
std::complex<double> zdl(jcl);
std::complex<long double> zlf(jcf);
std::complex<long double> zld(jcd);
std::complex<long double> zll(jcl);
std::complex<float> wff = jcf;
std::complex<float> wfd = jcd;
std::complex<float> wfl = jcl;
std::complex<double> wdf = jcf;
std::complex<double> wdd = jcd;
std::complex<double> wdl = jcl;
std::complex<long double> wlf = jcf;
std::complex<long double> wld = jcd;
std::complex<long double> wll = jcl;
//jcd = jd; // Fails.
// Try some arithmetic.
//std::complex<double> a = jcd + jd; // Fails.
//std::complex<double> b = jd + jcd; // Fails.
return 0;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-02-21 21:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-21 22:00 C99 _Complex and C++ complex<> interoperability Smith-Rowland, Edward M
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).