1*4684ddb6SLionel Sambuc //===----------------------------------------------------------------------===//
2*4684ddb6SLionel Sambuc //
3*4684ddb6SLionel Sambuc // The LLVM Compiler Infrastructure
4*4684ddb6SLionel Sambuc //
5*4684ddb6SLionel Sambuc // This file is dual licensed under the MIT and the University of Illinois Open
6*4684ddb6SLionel Sambuc // Source Licenses. See LICENSE.TXT for details.
7*4684ddb6SLionel Sambuc //
8*4684ddb6SLionel Sambuc //===----------------------------------------------------------------------===//
9*4684ddb6SLionel Sambuc
10*4684ddb6SLionel Sambuc // <complex>
11*4684ddb6SLionel Sambuc
12*4684ddb6SLionel Sambuc // constexpr complex(const T& re = T(), const T& im = T());
13*4684ddb6SLionel Sambuc
14*4684ddb6SLionel Sambuc #include <complex>
15*4684ddb6SLionel Sambuc #include <cassert>
16*4684ddb6SLionel Sambuc
17*4684ddb6SLionel Sambuc template <class T>
18*4684ddb6SLionel Sambuc void
test()19*4684ddb6SLionel Sambuc test()
20*4684ddb6SLionel Sambuc {
21*4684ddb6SLionel Sambuc {
22*4684ddb6SLionel Sambuc const std::complex<T> c;
23*4684ddb6SLionel Sambuc assert(c.real() == 0);
24*4684ddb6SLionel Sambuc assert(c.imag() == 0);
25*4684ddb6SLionel Sambuc }
26*4684ddb6SLionel Sambuc {
27*4684ddb6SLionel Sambuc const std::complex<T> c = 7.5;
28*4684ddb6SLionel Sambuc assert(c.real() == 7.5);
29*4684ddb6SLionel Sambuc assert(c.imag() == 0);
30*4684ddb6SLionel Sambuc }
31*4684ddb6SLionel Sambuc {
32*4684ddb6SLionel Sambuc const std::complex<T> c(8.5);
33*4684ddb6SLionel Sambuc assert(c.real() == 8.5);
34*4684ddb6SLionel Sambuc assert(c.imag() == 0);
35*4684ddb6SLionel Sambuc }
36*4684ddb6SLionel Sambuc {
37*4684ddb6SLionel Sambuc const std::complex<T> c(10.5, -9.5);
38*4684ddb6SLionel Sambuc assert(c.real() == 10.5);
39*4684ddb6SLionel Sambuc assert(c.imag() == -9.5);
40*4684ddb6SLionel Sambuc }
41*4684ddb6SLionel Sambuc #ifndef _LIBCPP_HAS_NO_CONSTEXPR
42*4684ddb6SLionel Sambuc {
43*4684ddb6SLionel Sambuc constexpr std::complex<T> c;
44*4684ddb6SLionel Sambuc static_assert(c.real() == 0, "");
45*4684ddb6SLionel Sambuc static_assert(c.imag() == 0, "");
46*4684ddb6SLionel Sambuc }
47*4684ddb6SLionel Sambuc {
48*4684ddb6SLionel Sambuc constexpr std::complex<T> c = 7.5;
49*4684ddb6SLionel Sambuc static_assert(c.real() == 7.5, "");
50*4684ddb6SLionel Sambuc static_assert(c.imag() == 0, "");
51*4684ddb6SLionel Sambuc }
52*4684ddb6SLionel Sambuc {
53*4684ddb6SLionel Sambuc constexpr std::complex<T> c(8.5);
54*4684ddb6SLionel Sambuc static_assert(c.real() == 8.5, "");
55*4684ddb6SLionel Sambuc static_assert(c.imag() == 0, "");
56*4684ddb6SLionel Sambuc }
57*4684ddb6SLionel Sambuc {
58*4684ddb6SLionel Sambuc constexpr std::complex<T> c(10.5, -9.5);
59*4684ddb6SLionel Sambuc static_assert(c.real() == 10.5, "");
60*4684ddb6SLionel Sambuc static_assert(c.imag() == -9.5, "");
61*4684ddb6SLionel Sambuc }
62*4684ddb6SLionel Sambuc #endif
63*4684ddb6SLionel Sambuc }
64*4684ddb6SLionel Sambuc
main()65*4684ddb6SLionel Sambuc int main()
66*4684ddb6SLionel Sambuc {
67*4684ddb6SLionel Sambuc test<float>();
68*4684ddb6SLionel Sambuc test<double>();
69*4684ddb6SLionel Sambuc test<long double>();
70*4684ddb6SLionel Sambuc }
71