diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst --- a/libcxx/docs/FeatureTestMacroTable.rst +++ b/libcxx/docs/FeatureTestMacroTable.rst @@ -198,6 +198,8 @@ ------------------------------------------------- ----------------- ``__cpp_lib_list_remove_return_type`` ``201806L`` ------------------------------------------------- ----------------- + ``__cpp_lib_math_constants`` ``201907L`` + ------------------------------------------------- ----------------- ``__cpp_lib_ranges`` *unimplemented* ------------------------------------------------- ----------------- ``__cpp_lib_span`` ``202002L`` diff --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst --- a/libcxx/docs/ReleaseNotes.rst +++ b/libcxx/docs/ReleaseNotes.rst @@ -38,6 +38,8 @@ New Features ------------ +- ```` + API Changes ----------- - ... diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -117,6 +117,7 @@ module.modulemap mutex new + numbers numeric optional ostream diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap --- a/libcxx/include/module.modulemap +++ b/libcxx/include/module.modulemap @@ -378,6 +378,10 @@ header "new" export * } + module numbers { + header "numbers" + export * + } module numeric { header "numeric" export * diff --git a/libcxx/include/numbers b/libcxx/include/numbers new file mode 100644 --- /dev/null +++ b/libcxx/include/numbers @@ -0,0 +1,141 @@ +// -*- C++ -*- +//===---------------------------- numbers ---------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_NUMBERS +#define _LIBCPP_NUMBERS + +/* + numbers synopsis + +namespace std::numbers { + template inline constexpr T e_v = unspecified; + template inline constexpr T log2e_v = unspecified; + template inline constexpr T log10e_v = unspecified; + template inline constexpr T pi_v = unspecified; + template inline constexpr T inv_pi_v = unspecified; + template inline constexpr T inv_sqrtpi_v = unspecified; + template inline constexpr T ln2_v = unspecified; + template inline constexpr T ln10_v = unspecified; + template inline constexpr T sqrt2_v = unspecified; + template inline constexpr T sqrt3_v = unspecified; + template inline constexpr T inv_sqrt3_v = unspecified; + template inline constexpr T egamma_v = unspecified; + template inline constexpr T phi_v = unspecified; + + template inline constexpr T e_v = see below; + template inline constexpr T log2e_v = see below; + template inline constexpr T log10e_v = see below; + template inline constexpr T pi_v = see below; + template inline constexpr T inv_pi_v = see below; + template inline constexpr T inv_sqrtpi_v = see below; + template inline constexpr T ln2_v = see below; + template inline constexpr T ln10_v = see below; + template inline constexpr T sqrt2_v = see below; + template inline constexpr T sqrt3_v = see below; + template inline constexpr T inv_sqrt3_v = see below; + template inline constexpr T egamma_v = see below; + template inline constexpr T phi_v = see below; + + inline constexpr double e = e_v; + inline constexpr double log2e = log2e_v; + inline constexpr double log10e = log10e_v; + inline constexpr double pi = pi_v; + inline constexpr double inv_pi = inv_pi_v; + inline constexpr double inv_sqrtpi = inv_sqrtpi_v; + inline constexpr double ln2 = ln2_v; + inline constexpr double ln10 = ln10_v; + inline constexpr double sqrt2 = sqrt2_v; + inline constexpr double sqrt3 = sqrt3_v; + inline constexpr double inv_sqrt3 = inv_sqrt3_v; + inline constexpr double egamma = egamma_v; + inline constexpr double phi = phi_v; +} +*/ + +#include <__config> + +#if _LIBCPP_STD_VER > 17 + +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace numbers { + +template +inline constexpr bool __false = false; + +template +struct __illformed +{ + static_assert(__false, "A program that instantiates a primary template of a mathematical constant variable template is ill-formed."); +}; + +template inline constexpr T e_v = __illformed{}; +template inline constexpr T log2e_v = __illformed{}; +template inline constexpr T log10e_v = __illformed{}; +template inline constexpr T pi_v = __illformed{}; +template inline constexpr T inv_pi_v = __illformed{}; +template inline constexpr T inv_sqrtpi_v = __illformed{}; +template inline constexpr T ln2_v = __illformed{}; +template inline constexpr T ln10_v = __illformed{}; +template inline constexpr T sqrt2_v = __illformed{}; +template inline constexpr T sqrt3_v = __illformed{}; +template inline constexpr T inv_sqrt3_v = __illformed{}; +template inline constexpr T egamma_v = __illformed{}; +template inline constexpr T phi_v = __illformed{}; + +template +concept __floating_point = std::is_floating_point_v; + +template <__floating_point T> inline constexpr T e_v = 2.718281828459045235360287471352662; +template <__floating_point T> inline constexpr T log2e_v = 1.442695040888963407359924681001892; +template <__floating_point T> inline constexpr T log10e_v = 0.434294481903251827651128918916605; +template <__floating_point T> inline constexpr T pi_v = 3.141592653589793238462643383279502; +template <__floating_point T> inline constexpr T inv_pi_v = 0.318309886183790671537767526745028; +template <__floating_point T> inline constexpr T inv_sqrtpi_v = 0.564189583547756286948079451560772; +template <__floating_point T> inline constexpr T ln2_v = 0.693147180559945309417232121458176; +template <__floating_point T> inline constexpr T ln10_v = 2.302585092994045684017991454684364; +template <__floating_point T> inline constexpr T sqrt2_v = 1.414213562373095048801688724209698; +template <__floating_point T> inline constexpr T sqrt3_v = 1.732050807568877293527446341505872; +template <__floating_point T> inline constexpr T inv_sqrt3_v = 0.577350269189625764509148780501957; +template <__floating_point T> inline constexpr T egamma_v = 0.577215664901532860606512090082402; +template <__floating_point T> inline constexpr T phi_v = 1.618033988749894848204586834365638; + +inline constexpr double e = e_v; +inline constexpr double log2e = log2e_v; +inline constexpr double log10e = log10e_v; +inline constexpr double pi = pi_v; +inline constexpr double inv_pi = inv_pi_v; +inline constexpr double inv_sqrtpi = inv_sqrtpi_v; +inline constexpr double ln2 = ln2_v; +inline constexpr double ln10 = ln10_v; +inline constexpr double sqrt2 = sqrt2_v; +inline constexpr double sqrt3 = sqrt3_v; +inline constexpr double inv_sqrt3 = inv_sqrt3_v; +inline constexpr double egamma = egamma_v; +inline constexpr double phi = phi_v; + +} // namespace numbers + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif //_LIBCPP_STD_VER > 17 + +#endif // _LIBCPP_NUMBERS diff --git a/libcxx/include/version b/libcxx/include/version --- a/libcxx/include/version +++ b/libcxx/include/version @@ -75,6 +75,7 @@ __cpp_lib_make_reverse_iterator 201402L __cpp_lib_make_unique 201304L __cpp_lib_map_try_emplace 201411L +__cpp_lib_math_constants 201907L __cpp_lib_math_special_functions 201603L __cpp_lib_memory_resource 201603L __cpp_lib_node_extract 201606L @@ -237,6 +238,7 @@ # define __cpp_lib_is_constant_evaluated 201811L # endif # define __cpp_lib_list_remove_return_type 201806L +# define __cpp_lib_math_constants 201907L // # define __cpp_lib_ranges 201811L # define __cpp_lib_span 202002L // # define __cpp_lib_three_way_comparison 201711L diff --git a/libcxx/test/libcxx/double_include.sh.cpp b/libcxx/test/libcxx/double_include.sh.cpp --- a/libcxx/test/libcxx/double_include.sh.cpp +++ b/libcxx/test/libcxx/double_include.sh.cpp @@ -97,6 +97,7 @@ #include #endif #include +#include #include #include #include diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/numbers.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/numbers.version.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/numbers.version.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_feature_test_macro_components.py +// and should not be edited manually. + +// + +// Test the feature test macros defined by + +/* Constant Value + __cpp_lib_math_constants 201907L [C++2a] +*/ + +#include +#include "test_macros.h" + +#if TEST_STD_VER < 14 + +# ifdef __cpp_lib_math_constants +# error "__cpp_lib_math_constants should not be defined before c++2a" +# endif + +#elif TEST_STD_VER == 14 + +# ifdef __cpp_lib_math_constants +# error "__cpp_lib_math_constants should not be defined before c++2a" +# endif + +#elif TEST_STD_VER == 17 + +# ifdef __cpp_lib_math_constants +# error "__cpp_lib_math_constants should not be defined before c++2a" +# endif + +#elif TEST_STD_VER > 17 + +# ifndef __cpp_lib_math_constants +# error "__cpp_lib_math_constants should be defined in c++2a" +# endif +# if __cpp_lib_math_constants != 201907L +# error "__cpp_lib_math_constants should have the value 201907L in c++2a" +# endif + +#endif // TEST_STD_VER > 17 + +int main(int, char**) { return 0; } diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp --- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp @@ -67,6 +67,7 @@ __cpp_lib_make_reverse_iterator 201402L [C++14] __cpp_lib_make_unique 201304L [C++14] __cpp_lib_map_try_emplace 201411L [C++17] + __cpp_lib_math_constants 201907L [C++2a] __cpp_lib_math_special_functions 201603L [C++17] __cpp_lib_memory_resource 201603L [C++17] __cpp_lib_node_extract 201606L [C++17] @@ -317,6 +318,10 @@ # error "__cpp_lib_map_try_emplace should not be defined before c++17" # endif +# ifdef __cpp_lib_math_constants +# error "__cpp_lib_math_constants should not be defined before c++2a" +# endif + # ifdef __cpp_lib_math_special_functions # error "__cpp_lib_math_special_functions should not be defined before c++17" # endif @@ -693,6 +698,10 @@ # error "__cpp_lib_map_try_emplace should not be defined before c++17" # endif +# ifdef __cpp_lib_math_constants +# error "__cpp_lib_math_constants should not be defined before c++2a" +# endif + # ifdef __cpp_lib_math_special_functions # error "__cpp_lib_math_special_functions should not be defined before c++17" # endif @@ -1231,6 +1240,10 @@ # error "__cpp_lib_map_try_emplace should have the value 201411L in c++17" # endif +# ifdef __cpp_lib_math_constants +# error "__cpp_lib_math_constants should not be defined before c++2a" +# endif + # if !defined(_LIBCPP_VERSION) # ifndef __cpp_lib_math_special_functions # error "__cpp_lib_math_special_functions should be defined in c++17" @@ -1967,6 +1980,13 @@ # error "__cpp_lib_map_try_emplace should have the value 201411L in c++2a" # endif +# ifndef __cpp_lib_math_constants +# error "__cpp_lib_math_constants should be defined in c++2a" +# endif +# if __cpp_lib_math_constants != 201907L +# error "__cpp_lib_math_constants should have the value 201907L in c++2a" +# endif + # if !defined(_LIBCPP_VERSION) # ifndef __cpp_lib_math_special_functions # error "__cpp_lib_math_special_functions should be defined in c++2a" diff --git a/libcxx/test/std/numerics/numbers/defined.pass.cpp b/libcxx/test/std/numerics/numbers/defined.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/numerics/numbers/defined.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +#include + +// We are testing if these are defined by taking an address. Don't care if the result is unused. +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunused-variable" +#endif + +constexpr bool tests() { + const double* dd0{&std::numbers::e}; + const double* dd1{&std::numbers::log2e}; + const double* dd2{&std::numbers::log10e}; + const double* dd3{&std::numbers::pi}; + const double* dd4{&std::numbers::inv_pi}; + const double* dd5{&std::numbers::inv_sqrtpi}; + const double* dd6{&std::numbers::ln2}; + const double* dd7{&std::numbers::ln10}; + const double* dd8{&std::numbers::sqrt2}; + const double* dd9{&std::numbers::sqrt3}; + const double* dd10{&std::numbers::inv_sqrt3}; + const double* dd11{&std::numbers::egamma}; + const double* dd12{&std::numbers::phi}; + + const float* f0{&std::numbers::e_v}; + const float* f1{&std::numbers::log2e_v}; + const float* f2{&std::numbers::log10e_v}; + const float* f3{&std::numbers::pi_v}; + const float* f4{&std::numbers::inv_pi_v}; + const float* f5{&std::numbers::inv_sqrtpi_v}; + const float* f6{&std::numbers::ln2_v}; + const float* f7{&std::numbers::ln10_v}; + const float* f8{&std::numbers::sqrt2_v}; + const float* f9{&std::numbers::sqrt3_v}; + const float* f10{&std::numbers::inv_sqrt3_v}; + const float* f11{&std::numbers::egamma_v}; + const float* f12{&std::numbers::phi_v}; + + const double* d0{&std::numbers::e_v}; + const double* d1{&std::numbers::log2e_v}; + const double* d2{&std::numbers::log10e_v}; + const double* d3{&std::numbers::pi_v}; + const double* d4{&std::numbers::inv_pi_v}; + const double* d5{&std::numbers::inv_sqrtpi_v}; + const double* d6{&std::numbers::ln2_v}; + const double* d7{&std::numbers::ln10_v}; + const double* d8{&std::numbers::sqrt2_v}; + const double* d9{&std::numbers::sqrt3_v}; + const double* d10{&std::numbers::inv_sqrt3_v}; + const double* d11{&std::numbers::egamma_v}; + const double* d12{&std::numbers::phi_v}; + + const long double* ld0{&std::numbers::e_v}; + const long double* ld1{&std::numbers::log2e_v}; + const long double* ld2{&std::numbers::log10e_v}; + const long double* ld3{&std::numbers::pi_v}; + const long double* ld4{&std::numbers::inv_pi_v}; + const long double* ld5{&std::numbers::inv_sqrtpi_v}; + const long double* ld6{&std::numbers::ln2_v}; + const long double* ld7{&std::numbers::ln10_v}; + const long double* ld8{&std::numbers::sqrt2_v}; + const long double* ld9{&std::numbers::sqrt3_v}; + const long double* ld10{&std::numbers::inv_sqrt3_v}; + const long double* ld11{&std::numbers::egamma_v}; + const long double* ld12{&std::numbers::phi_v}; + + return true; +} + +static_assert(tests()); + +int main() { tests(); } diff --git a/libcxx/test/std/numerics/numbers/illformed.verify.cpp b/libcxx/test/std/numerics/numbers/illformed.verify.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/numerics/numbers/illformed.verify.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +#include + +// Initializing the primary template is ill-formed. +int log2e{std::numbers::log2e_v< + int>}; // expected-error-re@numbers:* {{static_assert failed {{.*}} "A program that instantiates a primary template of a mathematical constant variable template is ill-formed."}} +int log10e{std::numbers::log10e_v}; +int pi{std::numbers::pi_v}; +int inv_pi{std::numbers::inv_pi_v}; +int inv_sqrtpi{std::numbers::inv_sqrtpi_v}; +int ln2{std::numbers::ln2_v}; +int ln10{std::numbers::ln10_v}; +int sqrt2{std::numbers::sqrt2_v}; +int sqrt3{std::numbers::sqrt3_v}; +int inv_sqrt3{std::numbers::inv_sqrt3_v}; +int egamma{std::numbers::egamma_v}; +int phi{std::numbers::phi_v}; + +int main() { return 0; } diff --git a/libcxx/test/std/numerics/numbers/specialize.pass.cpp b/libcxx/test/std/numerics/numbers/specialize.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/numerics/numbers/specialize.pass.cpp @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +#include +#include + +// We are testing if template instantiation works. Don't care if the result is unused. +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunused-variable" +#endif + +constexpr bool tests() { + float f0{std::numbers::e_v}; + float f1{std::numbers::log2e_v}; + float f2{std::numbers::log10e_v}; + float f3{std::numbers::pi_v}; + float f4{std::numbers::inv_pi_v}; + float f5{std::numbers::inv_sqrtpi_v}; + float f6{std::numbers::ln2_v}; + float f7{std::numbers::ln10_v}; + float f8{std::numbers::sqrt2_v}; + float f9{std::numbers::sqrt3_v}; + float f10{std::numbers::inv_sqrt3_v}; + float f11{std::numbers::egamma_v}; + float f12{std::numbers::phi_v}; + + double d0{std::numbers::e_v}; + double d1{std::numbers::log2e_v}; + double d2{std::numbers::log10e_v}; + double d3{std::numbers::pi_v}; + double d4{std::numbers::inv_pi_v}; + double d5{std::numbers::inv_sqrtpi_v}; + double d6{std::numbers::ln2_v}; + double d7{std::numbers::ln10_v}; + double d8{std::numbers::sqrt2_v}; + double d9{std::numbers::sqrt3_v}; + double d10{std::numbers::inv_sqrt3_v}; + double d11{std::numbers::egamma_v}; + double d12{std::numbers::phi_v}; + + assert(d0 == std::numbers::e); + assert(d1 == std::numbers::log2e); + assert(d2 == std::numbers::log10e); + assert(d3 == std::numbers::pi); + assert(d4 == std::numbers::inv_pi); + assert(d5 == std::numbers::inv_sqrtpi); + assert(d6 == std::numbers::ln2); + assert(d7 == std::numbers::ln10); + assert(d8 == std::numbers::sqrt2); + assert(d9 == std::numbers::sqrt3); + assert(d10 == std::numbers::inv_sqrt3); + assert(d11 == std::numbers::egamma); + assert(d12 == std::numbers::phi); + + long double ld0{std::numbers::e_v}; + long double ld1{std::numbers::log2e_v}; + long double ld2{std::numbers::log10e_v}; + long double ld3{std::numbers::pi_v}; + long double ld4{std::numbers::inv_pi_v}; + long double ld5{std::numbers::inv_sqrtpi_v}; + long double ld6{std::numbers::ln2_v}; + long double ld7{std::numbers::ln10_v}; + long double ld8{std::numbers::sqrt2_v}; + long double ld9{std::numbers::sqrt3_v}; + long double ld10{std::numbers::inv_sqrt3_v}; + long double ld11{std::numbers::egamma_v}; + long double ld12{std::numbers::phi_v}; + + return true; +} + +static_assert(tests()); + +int main() { tests(); } diff --git a/libcxx/test/std/numerics/numbers/user_type.pass.cpp b/libcxx/test/std/numerics/numbers/user_type.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/numerics/numbers/user_type.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +#include + +struct user { + int value; +}; + +template <> +user std::numbers::e_v{}; + +template <> +user std::numbers::log2e_v{}; + +template <> +user std::numbers::log10e_v{}; + +template <> +user std::numbers::pi_v{}; + +template <> +user std::numbers::inv_pi_v{}; + +template <> +user std::numbers::inv_sqrtpi_v{}; + +template <> +user std::numbers::ln2_v{}; + +template <> +user std::numbers::ln10_v{}; + +template <> +user std::numbers::sqrt2_v{}; + +template <> +user std::numbers::sqrt3_v{}; + +template <> +user std::numbers::inv_sqrt3_v{}; + +template <> +user std::numbers::egamma_v{}; + +template <> +user std::numbers::phi_v{}; + +int main() { return 0; } diff --git a/libcxx/test/std/numerics/numbers/value.pass.cpp b/libcxx/test/std/numerics/numbers/value.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/numerics/numbers/value.pass.cpp @@ -0,0 +1,85 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +#include +#include + +constexpr bool tests() { + assert(std::numbers::e == 0x1.5bf0a8b145769p+1); + assert(std::numbers::e_v == 0x1.5bf0a8b145769p+1); + assert(std::numbers::e_v == 0x1.5bf0a8b145769p+1l); + assert(std::numbers::e_v == 0x1.5bf0a8p+1f); + + assert(std::numbers::log2e == 0x1.71547652b82fep+0); + assert(std::numbers::log2e_v == 0x1.71547652b82fep+0); + assert(std::numbers::log2e_v == 0x1.71547652b82fep+0l); + assert(std::numbers::log2e_v == 0x1.715476p+0f); + + assert(std::numbers::log10e == 0x1.bcb7b1526e50ep-2); + assert(std::numbers::log10e_v == 0x1.bcb7b1526e50ep-2); + assert(std::numbers::log10e_v == 0x1.bcb7b1526e50ep-2l); + assert(std::numbers::log10e_v == 0x1.bcb7b15p-2f); + + assert(std::numbers::pi == 0x1.921fb54442d18p+1); + assert(std::numbers::pi_v == 0x1.921fb54442d18p+1); + assert(std::numbers::pi_v == 0x1.921fb54442d18p+1l); + assert(std::numbers::pi_v == 0x1.921fb54p+1f); + + assert(std::numbers::inv_pi == 0x1.45f306dc9c883p-2); + assert(std::numbers::inv_pi_v == 0x1.45f306dc9c883p-2); + assert(std::numbers::inv_pi_v == 0x1.45f306dc9c883p-2l); + assert(std::numbers::inv_pi_v == 0x1.45f306p-2f); + + assert(std::numbers::inv_sqrtpi == 0x1.20dd750429b6dp-1); + assert(std::numbers::inv_sqrtpi_v == 0x1.20dd750429b6dp-1); + assert(std::numbers::inv_sqrtpi_v == 0x1.20dd750429b6dp-1l); + assert(std::numbers::inv_sqrtpi_v == 0x1.20dd76p-1f); + + assert(std::numbers::ln2 == 0x1.62e42fefa39efp-1); + assert(std::numbers::ln2_v == 0x1.62e42fefa39efp-1); + assert(std::numbers::ln2_v == 0x1.62e42fefa39efp-1l); + assert(std::numbers::ln2_v == 0x1.62e42fp-1f); + + assert(std::numbers::ln10 == 0x1.26bb1bbb55516p+1); + assert(std::numbers::ln10_v == 0x1.26bb1bbb55516p+1); + assert(std::numbers::ln10_v == 0x1.26bb1bbb55516p+1l); + assert(std::numbers::ln10_v == 0x1.26bb1bp+1f); + + assert(std::numbers::sqrt2 == 0x1.6a09e667f3bcdp+0); + assert(std::numbers::sqrt2_v == 0x1.6a09e667f3bcdp+0); + assert(std::numbers::sqrt2_v == 0x1.6a09e667f3bcdp+0l); + assert(std::numbers::sqrt2_v == 0x1.6a09e6p+0f); + + assert(std::numbers::sqrt3 == 0x1.bb67ae8584caap+0); + assert(std::numbers::sqrt3_v == 0x1.bb67ae8584caap+0); + assert(std::numbers::sqrt3_v == 0x1.bb67ae8584caap+0l); + assert(std::numbers::sqrt3_v == 0x1.bb67aep+0f); + + assert(std::numbers::inv_sqrt3 == 0x1.279a74590331cp-1); + assert(std::numbers::inv_sqrt3_v == 0x1.279a74590331cp-1); + assert(std::numbers::inv_sqrt3_v == 0x1.279a74590331cp-1l); + assert(std::numbers::inv_sqrt3_v == 0x1.279a74p-1f); + + assert(std::numbers::egamma == 0x1.2788cfc6fb619p-1); + assert(std::numbers::egamma_v == 0x1.2788cfc6fb619p-1); + assert(std::numbers::egamma_v == 0x1.2788cfc6fb619p-1l); + assert(std::numbers::egamma_v == 0x1.2788cfp-1f); + + assert(std::numbers::phi == 0x1.9e3779b97f4a8p+0); + assert(std::numbers::phi_v == 0x1.9e3779b97f4a8p+0); + assert(std::numbers::phi_v == 0x1.9e3779b97f4a8p+0l); + assert(std::numbers::phi_v == 0x1.9e3779ap+0f); + + return true; +} + +static_assert(tests()); + +int main() { tests(); } diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -599,6 +599,12 @@ }, "headers": ["span"], }, + {"name": "__cpp_lib_math_constants", + "values": { + "c++2a": int(201907), + }, + "headers": ["numbers"], + }, ]], key=lambda tc: tc["name"]) def get_std_dialects(): diff --git a/libcxx/www/cxx2a_status.html b/libcxx/www/cxx2a_status.html --- a/libcxx/www/cxx2a_status.html +++ b/libcxx/www/cxx2a_status.html @@ -161,7 +161,7 @@ P0408LWGEfficient Access to basic_stringbuf ’s BufferCologne P0466LWGLayout-compatibility and Pointer-interconvertibility TraitsCologne P0553LWGBit operationsCologneComplete9.0 - P0631LWGMath ConstantsCologne + P0631LWGMath ConstantsCologneComplete11.0 P0645LWGText FormattingCologne P0660LWGStop Token and Joining Thread, Rev 10Cologne P0784CWGMore constexpr containersCologne