1320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow//===----------------------------------------------------------------------===//
2320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow//
3320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow//                     The LLVM Compiler Infrastructure
4320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow//
5320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow// This file is dual licensed under the MIT and the University of Illinois Open
6320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow// Source Licenses. See LICENSE.TXT for details.
7320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow//
8320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow//===----------------------------------------------------------------------===//
9320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow
10320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow// <chrono>
11320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow
12320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow#include <complex>
13320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow#include <type_traits>
14320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow#include <cassert>
15320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow
16320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clowint main()
17320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow{
18320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow#if _LIBCPP_STD_VER > 11
19320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    using namespace std::literals::complex_literals;
20320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow
21320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow//  Make sure the types are right
22320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    static_assert ( std::is_same<decltype( 3.0il ), std::complex<long double>>::value, "" );
23320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    static_assert ( std::is_same<decltype( 3il   ), std::complex<long double>>::value, "" );
24320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    static_assert ( std::is_same<decltype( 3.0i  ), std::complex<double>>::value, "" );
25320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    static_assert ( std::is_same<decltype( 3i    ), std::complex<double>>::value, "" );
26320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    static_assert ( std::is_same<decltype( 3.0if ), std::complex<float>>::value, "" );
27320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    static_assert ( std::is_same<decltype( 3if   ), std::complex<float>>::value, "" );
28320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow
29320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    {
30320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    std::complex<long double> c1 = 3.0il;
31320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    assert ( c1 == std::complex<long double>(0, 3.0));
32320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    auto c2 = 3il;
33320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    assert ( c1 == c2 );
34320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    }
35320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow
36320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    {
37320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    std::complex<double> c1 = 3.0i;
38320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    assert ( c1 == std::complex<double>(0, 3.0));
39320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    auto c2 = 3i;
40320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    assert ( c1 == c2 );
41320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    }
42320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow
43320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    {
44320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    std::complex<float> c1 = 3.0if;
45320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    assert ( c1 == std::complex<float>(0, 3.0));
46320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    auto c2 = 3if;
47320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    assert ( c1 == c2 );
48320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow    }
49320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow
50320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow#endif
51320c80fecf6b50cbc89840189b90a972baf4d6fcMarshall Clow}
52