1*4684ddb6SLionel Sambuc //===----------------------------------------------------------------------===//
2*4684ddb6SLionel Sambuc //
3*4684ddb6SLionel Sambuc // The LLVM Compiler Infrastructure
4*4684ddb6SLionel Sambuc //
5*4684ddb6SLionel Sambuc // This file is dual licensed under the MIT and the University of Illinois Open
6*4684ddb6SLionel Sambuc // Source Licenses. See LICENSE.TXT for details.
7*4684ddb6SLionel Sambuc //
8*4684ddb6SLionel Sambuc //===----------------------------------------------------------------------===//
9*4684ddb6SLionel Sambuc
10*4684ddb6SLionel Sambuc // <chrono>
11*4684ddb6SLionel Sambuc
12*4684ddb6SLionel Sambuc #include <complex>
13*4684ddb6SLionel Sambuc #include <type_traits>
14*4684ddb6SLionel Sambuc #include <cassert>
15*4684ddb6SLionel Sambuc
main()16*4684ddb6SLionel Sambuc int main()
17*4684ddb6SLionel Sambuc {
18*4684ddb6SLionel Sambuc #if _LIBCPP_STD_VER > 11
19*4684ddb6SLionel Sambuc using namespace std::literals::complex_literals;
20*4684ddb6SLionel Sambuc
21*4684ddb6SLionel Sambuc // Make sure the types are right
22*4684ddb6SLionel Sambuc static_assert ( std::is_same<decltype( 3.0il ), std::complex<long double>>::value, "" );
23*4684ddb6SLionel Sambuc static_assert ( std::is_same<decltype( 3il ), std::complex<long double>>::value, "" );
24*4684ddb6SLionel Sambuc static_assert ( std::is_same<decltype( 3.0i ), std::complex<double>>::value, "" );
25*4684ddb6SLionel Sambuc static_assert ( std::is_same<decltype( 3i ), std::complex<double>>::value, "" );
26*4684ddb6SLionel Sambuc static_assert ( std::is_same<decltype( 3.0if ), std::complex<float>>::value, "" );
27*4684ddb6SLionel Sambuc static_assert ( std::is_same<decltype( 3if ), std::complex<float>>::value, "" );
28*4684ddb6SLionel Sambuc
29*4684ddb6SLionel Sambuc {
30*4684ddb6SLionel Sambuc std::complex<long double> c1 = 3.0il;
31*4684ddb6SLionel Sambuc assert ( c1 == std::complex<long double>(0, 3.0));
32*4684ddb6SLionel Sambuc auto c2 = 3il;
33*4684ddb6SLionel Sambuc assert ( c1 == c2 );
34*4684ddb6SLionel Sambuc }
35*4684ddb6SLionel Sambuc
36*4684ddb6SLionel Sambuc {
37*4684ddb6SLionel Sambuc std::complex<double> c1 = 3.0i;
38*4684ddb6SLionel Sambuc assert ( c1 == std::complex<double>(0, 3.0));
39*4684ddb6SLionel Sambuc auto c2 = 3i;
40*4684ddb6SLionel Sambuc assert ( c1 == c2 );
41*4684ddb6SLionel Sambuc }
42*4684ddb6SLionel Sambuc
43*4684ddb6SLionel Sambuc {
44*4684ddb6SLionel Sambuc std::complex<float> c1 = 3.0if;
45*4684ddb6SLionel Sambuc assert ( c1 == std::complex<float>(0, 3.0));
46*4684ddb6SLionel Sambuc auto c2 = 3if;
47*4684ddb6SLionel Sambuc assert ( c1 == c2 );
48*4684ddb6SLionel Sambuc }
49*4684ddb6SLionel Sambuc
50*4684ddb6SLionel Sambuc #endif
51*4684ddb6SLionel Sambuc }
52