blob: a9f356d4a40aeb78a5cb7a14293e2c46d2273335 [file] [log] [blame]
Dan Albert287553d2017-02-16 10:47:51 -08001//===----------------------------------------------------------------------===//
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
15template <class T>
16void
17test()
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
31int main()
32{
33 test<float>();
34 test<double>();
35 test<long double>();
36}