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 // void real(T val); // constexpr in C++20
12 // void imag(T val); // constexpr in C++20
17 #include "test_macros.h"
25 constexpr std::complex<T
> c1
;
26 static_assert(c1
.real() == 0, "");
27 static_assert(c1
.imag() == 0, "");
28 constexpr std::complex<T
> c2(3);
29 static_assert(c2
.real() == 3, "");
30 static_assert(c2
.imag() == 0, "");
31 constexpr std::complex<T
> c3(3, 4);
32 static_assert(c3
.real() == 3, "");
33 static_assert(c3
.imag() == 4, "");
43 assert(c
.real() == 0);
44 assert(c
.imag() == 0);
46 assert(c
.real() == 3.5);
47 assert(c
.imag() == 0);
49 assert(c
.real() == 3.5);
50 assert(c
.imag() == 4.5);
52 assert(c
.real() == -4.5);
53 assert(c
.imag() == 4.5);
55 assert(c
.real() == -4.5);
56 assert(c
.imag() == -5.5);
62 int main(int, char**) {
66 test_constexpr
<int>();
68 #if TEST_STD_VER >= 20
69 static_assert(test
<float>());
70 static_assert(test
<double>());
71 static_assert(test
<long double>());