Home | History | Annotate | Download | only in complex.number
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // <complex>
     11 
     12 #include <complex>
     13 #include <cassert>
     14 
     15 template <class T>
     16 void
     17 test()
     18 {
     19     std::complex<T> z;
     20     T* a = (T*)&z;
     21     assert(0 == z.real());
     22     assert(0 == z.imag());
     23     assert(a[0] == z.real());
     24     assert(a[1] == z.imag());
     25     a[0] = 5;
     26     a[1] = 6;
     27     assert(a[0] == z.real());
     28     assert(a[1] == z.imag());
     29 }
     30 
     31 int main()
     32 {
     33     test<float>();
     34     test<double>();
     35     test<long double>();
     36 }
     37