Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / numerics / complex.number / cmplx.over / proj.pass.cpp
bloba395f6d6bdd9b19f02976aaeb3b244ff4ed9793f
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> proj(const complex<T>&);
12 // complex<long double> proj(long double);
13 // complex<double> proj(double);
14 // template<Integral T> complex<double> proj(T);
15 // complex<float> proj(float);
17 #include <complex>
18 #include <type_traits>
19 #include <cassert>
21 #include "test_macros.h"
22 #include "../cases.h"
24 template <class T>
25 void
26 test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
28 static_assert((std::is_same<decltype(std::proj(x)), std::complex<double> >::value), "");
29 assert(std::proj(x) == proj(std::complex<double>(x, 0)));
32 template <class T>
33 void
34 test(T x, typename std::enable_if<std::is_floating_point<T>::value>::type* = 0)
36 static_assert((std::is_same<decltype(std::proj(x)), std::complex<T> >::value), "");
37 assert(std::proj(x) == proj(std::complex<T>(x, 0)));
40 template <class T>
41 void
42 test(T x, typename std::enable_if<!std::is_integral<T>::value &&
43 !std::is_floating_point<T>::value>::type* = 0)
45 static_assert((std::is_same<decltype(std::proj(x)), std::complex<T> >::value), "");
46 assert(std::proj(x) == proj(std::complex<T>(x, 0)));
49 template <class T>
50 void
51 test()
53 test<T>(0);
54 test<T>(1);
55 test<T>(10);
58 int main(int, char**)
60 test<float>();
61 test<double>();
62 test<long double>();
63 test<int>();
64 test<unsigned>();
65 test<long long>();
67 return 0;