1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <complex>
10 
11 #include <complex>
12 #include <cassert>
13 
14 template <class T>
15 void
16 test()
17 {
18     std::complex<T> z;
19     T* a = (T*)&z;
20     assert(0 == z.real());
21     assert(0 == z.imag());
22     assert(a[0] == z.real());
23     assert(a[1] == z.imag());
24     a[0] = 5;
25     a[1] = 6;
26     assert(a[0] == z.real());
27     assert(a[1] == z.imag());
28 }
29 
30 int main(int, char**)
31 {
32     test<float>();
33     test<double>();
34     test<long double>();
35 
36   return 0;
37 }
38