Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / numerics / complex.number / cmplx.over / conj.pass.cpp
blob553ead653bbf501a08dc71247e81d405789f3173
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // <complex>
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
17 #include <complex>
18 #include <type_traits>
19 #include <cassert>
21 #include "test_macros.h"
22 #include "../cases.h"
24 template <class T>
25 TEST_CONSTEXPR_CXX20
26 void
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)));
33 template <class T>
34 TEST_CONSTEXPR_CXX20
35 void
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)));
42 template <class T>
43 TEST_CONSTEXPR_CXX20
44 void
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)));
52 template <class T>
53 TEST_CONSTEXPR_CXX20
54 bool
55 test()
57 test<T>(0);
58 test<T>(1);
59 test<T>(10);
60 return true;
63 int main(int, char**)
65 test<float>();
66 test<double>();
67 test<long double>();
68 test<int>();
69 test<unsigned>();
70 test<long long>();
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>());
79 #endif
81 return 0;