• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <complex>
11 
12 // template<class T>    complex<T>           proj(const complex<T>&);
13 //                      complex<long double> proj(long double);
14 //                      complex<double>      proj(double);
15 // template<Integral T> complex<double>      proj(T);
16 //                      complex<float>       proj(float);
17 
18 #include <complex>
19 #include <type_traits>
20 #include <cassert>
21 
22 #include "../cases.h"
23 
24 template <class T>
25 void
test(T x,typename std::enable_if<std::is_integral<T>::value>::type * =0)26 test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
27 {
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)));
30 }
31 
32 template <class T>
33 void
test(T x,typename std::enable_if<std::is_floating_point<T>::value>::type * =0)34 test(T x, typename std::enable_if<std::is_floating_point<T>::value>::type* = 0)
35 {
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)));
38 }
39 
40 template <class T>
41 void
test(T x,typename std::enable_if<!std::is_integral<T>::value &&!std::is_floating_point<T>::value>::type * =0)42 test(T x, typename std::enable_if<!std::is_integral<T>::value &&
43                                   !std::is_floating_point<T>::value>::type* = 0)
44 {
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)));
47 }
48 
49 template <class T>
50 void
test()51 test()
52 {
53     test<T>(0);
54     test<T>(1);
55     test<T>(10);
56 }
57 
main()58 int main()
59 {
60     test<float>();
61     test<double>();
62     test<long double>();
63     test<int>();
64     test<unsigned>();
65     test<long long>();
66 }
67