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