]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/26_numerics/complex/operators/more_constexpr.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 26_numerics / complex / operators / more_constexpr.cc
CommitLineData
e987fb1e
ESR
1// { dg-options "-std=gnu++2a" }
2// { dg-do compile { target c++2a } }
3
8d9254fc 4// Copyright (C) 2018-2020 Free Software Foundation, Inc.
e987fb1e
ESR
5//
6// This file is part of the GNU ISO C++ Library. This library is free
7// software; you can redistribute it and/or modify it under the
8// terms of the GNU General Public License as published by the
9// Free Software Foundation; either version 3, or (at your option)
10// any later version.
11
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16
17// You should have received a copy of the GNU General Public License along
18// with this library; see the file COPYING3. If not see
19// <http://www.gnu.org/licenses/>.
20
21#include <complex>
22#include <testsuite_common_types.h>
23
24namespace __gnu_test
25{
26 // Test constexpr symmetric complex @ real, real @ complex, complex @ complex.
27 template<typename _Tp>
28 void
29 test_operators()
30 {
31 constexpr std::complex<_Tp> a{1, 2};
32 constexpr std::complex<_Tp> b{3, 4};
33 constexpr _Tp c = 5;
34
35 constexpr auto w [[maybe_unused]] = +a;
36 constexpr auto z [[maybe_unused]] = -a;
37
38 constexpr auto apc [[maybe_unused]] = a + c;
39 constexpr auto amc [[maybe_unused]] = a - c;
40 constexpr auto atc [[maybe_unused]] = a * c;
41 constexpr auto adc [[maybe_unused]] = a / c;
42
43 constexpr auto cpa [[maybe_unused]] = c + a;
44 constexpr auto cma [[maybe_unused]] = c - a;
45 constexpr auto cta [[maybe_unused]] = c * a;
46 constexpr auto cda [[maybe_unused]] = c / a;
47
48 constexpr auto apb [[maybe_unused]] = a + b;
49 constexpr auto amb [[maybe_unused]] = a - b;
50 constexpr auto atb [[maybe_unused]] = a * b;
51 constexpr auto adb [[maybe_unused]] = a / b;
52 }
53}
54
55int main()
56{
57 __gnu_test::test_operators<float>();
58 __gnu_test::test_operators<double>();
c86fab9d 59#ifndef __LONG_DOUBLE_IBM128__ // IBM128 format is not constexpr foldable
e987fb1e 60 __gnu_test::test_operators<long double>();
c86fab9d 61#endif
e987fb1e
ESR
62
63 return 0;
64}