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<Arithmetic T>
13 // norm(T x); // constexpr in C++20
16 #include <type_traits>
19 #include "test_macros.h"
25 test(T x
, typename
std::enable_if
<std::is_integral
<T
>::value
>::type
* = 0)
27 static_assert((std::is_same
<decltype(std::norm(x
)), double>::value
), "");
28 assert(std::norm(x
) == norm(std::complex<double>(static_cast<double>(x
), 0)));
34 test(T x
, typename
std::enable_if
<!std::is_integral
<T
>::value
>::type
* = 0)
36 static_assert((std::is_same
<decltype(std::norm(x
)), T
>::value
), "");
37 assert(std::norm(x
) == norm(std::complex<T
>(x
, 0)));
60 #if TEST_STD_VER >= 20
61 static_assert(test
<float>());
62 static_assert(test
<double>());
63 static_assert(test
<long double>());
64 static_assert(test
<int>());
65 static_assert(test
<unsigned>());
66 static_assert(test
<long long>());