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//===----------------------------------------------------------------------===//
8
9// UNSUPPORTED: c++03, c++11, c++14, c++17
10
11#include <numbers>
12
13constexpr bool tests() {
14 [[maybe_unused]] const double* dd0{&std::numbers::e};
15 [[maybe_unused]] const double* dd1{&std::numbers::log2e};
16 [[maybe_unused]] const double* dd2{&std::numbers::log10e};
17 [[maybe_unused]] const double* dd3{&std::numbers::pi};
18 [[maybe_unused]] const double* dd4{&std::numbers::inv_pi};
19 [[maybe_unused]] const double* dd5{&std::numbers::inv_sqrtpi};
20 [[maybe_unused]] const double* dd6{&std::numbers::ln2};
21 [[maybe_unused]] const double* dd7{&std::numbers::ln10};
22 [[maybe_unused]] const double* dd8{&std::numbers::sqrt2};
23 [[maybe_unused]] const double* dd9{&std::numbers::sqrt3};
24 [[maybe_unused]] const double* dd10{&std::numbers::inv_sqrt3};
25 [[maybe_unused]] const double* dd11{&std::numbers::egamma};
26 [[maybe_unused]] const double* dd12{&std::numbers::phi};
27
28 [[maybe_unused]] const float* f0{&std::numbers::e_v<float>};
29 [[maybe_unused]] const float* f1{&std::numbers::log2e_v<float>};
30 [[maybe_unused]] const float* f2{&std::numbers::log10e_v<float>};
31 [[maybe_unused]] const float* f3{&std::numbers::pi_v<float>};
32 [[maybe_unused]] const float* f4{&std::numbers::inv_pi_v<float>};
33 [[maybe_unused]] const float* f5{&std::numbers::inv_sqrtpi_v<float>};
34 [[maybe_unused]] const float* f6{&std::numbers::ln2_v<float>};
35 [[maybe_unused]] const float* f7{&std::numbers::ln10_v<float>};
36 [[maybe_unused]] const float* f8{&std::numbers::sqrt2_v<float>};
37 [[maybe_unused]] const float* f9{&std::numbers::sqrt3_v<float>};
38 [[maybe_unused]] const float* f10{&std::numbers::inv_sqrt3_v<float>};
39 [[maybe_unused]] const float* f11{&std::numbers::egamma_v<float>};
40 [[maybe_unused]] const float* f12{&std::numbers::phi_v<float>};
41
42 [[maybe_unused]] const double* d0{&std::numbers::e_v<double>};
43 [[maybe_unused]] const double* d1{&std::numbers::log2e_v<double>};
44 [[maybe_unused]] const double* d2{&std::numbers::log10e_v<double>};
45 [[maybe_unused]] const double* d3{&std::numbers::pi_v<double>};
46 [[maybe_unused]] const double* d4{&std::numbers::inv_pi_v<double>};
47 [[maybe_unused]] const double* d5{&std::numbers::inv_sqrtpi_v<double>};
48 [[maybe_unused]] const double* d6{&std::numbers::ln2_v<double>};
49 [[maybe_unused]] const double* d7{&std::numbers::ln10_v<double>};
50 [[maybe_unused]] const double* d8{&std::numbers::sqrt2_v<double>};
51 [[maybe_unused]] const double* d9{&std::numbers::sqrt3_v<double>};
52 [[maybe_unused]] const double* d10{&std::numbers::inv_sqrt3_v<double>};
53 [[maybe_unused]] const double* d11{&std::numbers::egamma_v<double>};
54 [[maybe_unused]] const double* d12{&std::numbers::phi_v<double>};
55
56 [[maybe_unused]] const long double* ld0{&std::numbers::e_v<long double>};
57 [[maybe_unused]] const long double* ld1{&std::numbers::log2e_v<long double>};
58 [[maybe_unused]] const long double* ld2{&std::numbers::log10e_v<long double>};
59 [[maybe_unused]] const long double* ld3{&std::numbers::pi_v<long double>};
60 [[maybe_unused]] const long double* ld4{&std::numbers::inv_pi_v<long double>};
61 [[maybe_unused]] const long double* ld5{&std::numbers::inv_sqrtpi_v<long double>};
62 [[maybe_unused]] const long double* ld6{&std::numbers::ln2_v<long double>};
63 [[maybe_unused]] const long double* ld7{&std::numbers::ln10_v<long double>};
64 [[maybe_unused]] const long double* ld8{&std::numbers::sqrt2_v<long double>};
65 [[maybe_unused]] const long double* ld9{&std::numbers::sqrt3_v<long double>};
66 [[maybe_unused]] const long double* ld10{&std::numbers::inv_sqrt3_v<long double>};
67 [[maybe_unused]] const long double* ld11{&std::numbers::egamma_v<long double>};
68 [[maybe_unused]] const long double* ld12{&std::numbers::phi_v<long double>};
69
70 return true;
71}
72
73static_assert(tests());
74
75int main(int, char**) {
76 tests();
77 return 0;
78}
79

source code of libcxx/test/std/numerics/numbers/defined.pass.cpp