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 // UNSUPPORTED: c++98, c++03, c++11
11 // <chrono>
12
13 #include <complex>
14 #include <type_traits>
15 #include <cassert>
16
17 #include "test_macros.h"
18
main()19 int main()
20 {
21 using namespace std::literals::complex_literals;
22
23 // Make sure the types are right
24 static_assert ( std::is_same<decltype( 3.0il ), std::complex<long double>>::value, "" );
25 static_assert ( std::is_same<decltype( 3il ), std::complex<long double>>::value, "" );
26 static_assert ( std::is_same<decltype( 3.0i ), std::complex<double>>::value, "" );
27 static_assert ( std::is_same<decltype( 3i ), std::complex<double>>::value, "" );
28 static_assert ( std::is_same<decltype( 3.0if ), std::complex<float>>::value, "" );
29 static_assert ( std::is_same<decltype( 3if ), std::complex<float>>::value, "" );
30
31 {
32 std::complex<long double> c1 = 3.0il;
33 assert ( c1 == std::complex<long double>(0, 3.0));
34 auto c2 = 3il;
35 assert ( c1 == c2 );
36 }
37
38 {
39 std::complex<double> c1 = 3.0i;
40 assert ( c1 == std::complex<double>(0, 3.0));
41 auto c2 = 3i;
42 assert ( c1 == c2 );
43 }
44
45 {
46 std::complex<float> c1 = 3.0if;
47 assert ( c1 == std::complex<float>(0, 3.0));
48 auto c2 = 3if;
49 assert ( c1 == c2 );
50 }
51 }
52