1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // template<class T> complex<T> conj(const complex<T>&); // constexpr in C++20
12 // complex<long double> conj(long double); // constexpr in C++20
13 // complex<double> conj(double); // constexpr in C++20
14 // template<Integral T> complex<double> conj(T); // constexpr in C++20
15 // complex<float> conj(float); // constexpr in C++20
18 #include <type_traits>
21 #include "test_macros.h"
27 test(T x
, typename
std::enable_if
<std::is_integral
<T
>::value
>::type
* = 0)
29 static_assert((std::is_same
<decltype(std::conj(x
)), std::complex<double> >::value
), "");
30 assert(std::conj(x
) == conj(std::complex<double>(x
, 0)));
36 test(T x
, typename
std::enable_if
<std::is_floating_point
<T
>::value
>::type
* = 0)
38 static_assert((std::is_same
<decltype(std::conj(x
)), std::complex<T
> >::value
), "");
39 assert(std::conj(x
) == conj(std::complex<T
>(x
, 0)));
45 test(T x
, typename
std::enable_if
<!std::is_integral
<T
>::value
&&
46 !std::is_floating_point
<T
>::value
>::type
* = 0)
48 static_assert((std::is_same
<decltype(std::conj(x
)), std::complex<T
> >::value
), "");
49 assert(std::conj(x
) == conj(std::complex<T
>(x
, 0)));
72 #if TEST_STD_VER >= 20
73 static_assert(test
<float>());
74 static_assert(test
<double>());
75 static_assert(test
<long double>());
76 static_assert(test
<int>());
77 static_assert(test
<unsigned>());
78 static_assert(test
<long long>());