C99 _Complex and C++ complex<> interoperability.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
}


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux