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 // UNSUPPORTED: libcpp-no-concepts
11 
12 #include <cassert>
13 #include <numbers>
14 
15 // We are testing if template instantiation works. Don't care if the result is unused.
16 #if defined(__clang__)
17 #   pragma clang diagnostic ignored "-Wunused-variable"
18 #endif
19 
20 constexpr bool tests() {
21   float f0{std::numbers::e_v<float>};
22   float f1{std::numbers::log2e_v<float>};
23   float f2{std::numbers::log10e_v<float>};
24   float f3{std::numbers::pi_v<float>};
25   float f4{std::numbers::inv_pi_v<float>};
26   float f5{std::numbers::inv_sqrtpi_v<float>};
27   float f6{std::numbers::ln2_v<float>};
28   float f7{std::numbers::ln10_v<float>};
29   float f8{std::numbers::sqrt2_v<float>};
30   float f9{std::numbers::sqrt3_v<float>};
31   float f10{std::numbers::inv_sqrt3_v<float>};
32   float f11{std::numbers::egamma_v<float>};
33   float f12{std::numbers::phi_v<float>};
34 
35   double d0{std::numbers::e_v<double>};
36   double d1{std::numbers::log2e_v<double>};
37   double d2{std::numbers::log10e_v<double>};
38   double d3{std::numbers::pi_v<double>};
39   double d4{std::numbers::inv_pi_v<double>};
40   double d5{std::numbers::inv_sqrtpi_v<double>};
41   double d6{std::numbers::ln2_v<double>};
42   double d7{std::numbers::ln10_v<double>};
43   double d8{std::numbers::sqrt2_v<double>};
44   double d9{std::numbers::sqrt3_v<double>};
45   double d10{std::numbers::inv_sqrt3_v<double>};
46   double d11{std::numbers::egamma_v<double>};
47   double d12{std::numbers::phi_v<double>};
48 
49   assert(d0 == std::numbers::e);
50   assert(d1 == std::numbers::log2e);
51   assert(d2 == std::numbers::log10e);
52   assert(d3 == std::numbers::pi);
53   assert(d4 == std::numbers::inv_pi);
54   assert(d5 == std::numbers::inv_sqrtpi);
55   assert(d6 == std::numbers::ln2);
56   assert(d7 == std::numbers::ln10);
57   assert(d8 == std::numbers::sqrt2);
58   assert(d9 == std::numbers::sqrt3);
59   assert(d10 == std::numbers::inv_sqrt3);
60   assert(d11 == std::numbers::egamma);
61   assert(d12 == std::numbers::phi);
62 
63   long double ld0{std::numbers::e_v<long double>};
64   long double ld1{std::numbers::log2e_v<long double>};
65   long double ld2{std::numbers::log10e_v<long double>};
66   long double ld3{std::numbers::pi_v<long double>};
67   long double ld4{std::numbers::inv_pi_v<long double>};
68   long double ld5{std::numbers::inv_sqrtpi_v<long double>};
69   long double ld6{std::numbers::ln2_v<long double>};
70   long double ld7{std::numbers::ln10_v<long double>};
71   long double ld8{std::numbers::sqrt2_v<long double>};
72   long double ld9{std::numbers::sqrt3_v<long double>};
73   long double ld10{std::numbers::inv_sqrt3_v<long double>};
74   long double ld11{std::numbers::egamma_v<long double>};
75   long double ld12{std::numbers::phi_v<long double>};
76 
77   return true;
78 }
79 
80 static_assert(tests());
81 
82 int main() { tests(); }
83