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