15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier
9*31cbe0f2SLouis Dionne // UNSUPPORTED: c++03, c++11
105a83710eSEric Fiselier // <chrono>
115a83710eSEric Fiselier
125a83710eSEric Fiselier #include <complex>
135a83710eSEric Fiselier #include <type_traits>
145a83710eSEric Fiselier #include <cassert>
155a83710eSEric Fiselier
1669154d6eSEric Fiselier #include "test_macros.h"
1769154d6eSEric Fiselier
main(int,char **)182df59c50SJF Bastien int main(int, char**)
195a83710eSEric Fiselier {
205a83710eSEric Fiselier using namespace std::literals::complex_literals;
215a83710eSEric Fiselier
225a83710eSEric Fiselier // Make sure the types are right
235a83710eSEric Fiselier static_assert ( std::is_same<decltype( 3.0il ), std::complex<long double>>::value, "" );
245a83710eSEric Fiselier static_assert ( std::is_same<decltype( 3il ), std::complex<long double>>::value, "" );
255a83710eSEric Fiselier static_assert ( std::is_same<decltype( 3.0i ), std::complex<double>>::value, "" );
265a83710eSEric Fiselier static_assert ( std::is_same<decltype( 3i ), std::complex<double>>::value, "" );
275a83710eSEric Fiselier static_assert ( std::is_same<decltype( 3.0if ), std::complex<float>>::value, "" );
285a83710eSEric Fiselier static_assert ( std::is_same<decltype( 3if ), std::complex<float>>::value, "" );
295a83710eSEric Fiselier
305a83710eSEric Fiselier {
315a83710eSEric Fiselier std::complex<long double> c1 = 3.0il;
325a83710eSEric Fiselier assert ( c1 == std::complex<long double>(0, 3.0));
335a83710eSEric Fiselier auto c2 = 3il;
345a83710eSEric Fiselier assert ( c1 == c2 );
355a83710eSEric Fiselier }
365a83710eSEric Fiselier
375a83710eSEric Fiselier {
385a83710eSEric Fiselier std::complex<double> c1 = 3.0i;
395a83710eSEric Fiselier assert ( c1 == std::complex<double>(0, 3.0));
405a83710eSEric Fiselier auto c2 = 3i;
415a83710eSEric Fiselier assert ( c1 == c2 );
425a83710eSEric Fiselier }
435a83710eSEric Fiselier
445a83710eSEric Fiselier {
455a83710eSEric Fiselier std::complex<float> c1 = 3.0if;
465a83710eSEric Fiselier assert ( c1 == std::complex<float>(0, 3.0));
475a83710eSEric Fiselier auto c2 = 3if;
485a83710eSEric Fiselier assert ( c1 == c2 );
495a83710eSEric Fiselier }
502df59c50SJF Bastien
512df59c50SJF Bastien return 0;
525a83710eSEric Fiselier }
53