diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -118,6 +118,7 @@ mutex new numeric + numbers optional ostream queue diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap --- a/libcxx/include/module.modulemap +++ b/libcxx/include/module.modulemap @@ -382,6 +382,10 @@ header "numeric" export * } + module numbers { + header "numbers" + export * + } module optional { header "optional" export * diff --git a/libcxx/include/numbers b/libcxx/include/numbers new file mode 100644 --- /dev/null +++ b/libcxx/include/numbers @@ -0,0 +1,179 @@ +// -*- 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 +{ + 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; +} // std + +*/ + +#include <__config> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 17 + +template +using _IsFloat = _EnableIf, T>; + +// e +template +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR +T e_v = _IsFloat(2.718281828459045235360287471352663L); + +// log2(e) +template +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR +T log2e_v = _IsFloat(1.442695040888963407359924681001892L); + +// log10(e) +template +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR +T log10e_v = _IsFloat(0.4342944819032518276511289189166051L); + +// pi +template +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR +T pi_v = _IsFloat(3.141592653589793238462643383279503L); + +// 1/pi +template +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR +T inv_pi_v = _IsFloat(0.3183098861837906715377675267450287L); + +// 1/sqrt(pi) +template +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR +T inv_sqrtpi_v = _IsFloat(0.5641895835477562869480794515607726L); + +// log_e(2) +template +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR +T ln2_v = _IsFloat(0.6931471805599453094172321214581766L); + +// log_e(10) +template +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR +T ln10_v = _IsFloat(2.302585092994045684017991454684364L); + +// sqrt(2) +template +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR +T sqrt2_v = _IsFloat(1.414213562373095048801688724209698L); + +// sqrt(3) +template +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR +T sqrt3_v = _IsFloat(1.732050807568877293527446341505872L); + +// 1/sqrt(3) +template +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR +T inv_sqrt3_v = _IsFloat(0.5773502691896257645091487805019575L); + +// Euler-Mascheroni gama constant +template +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR +T egamma_v = _IsFloat(0.5772156649015328606065120900824024L); + +// Golden ratio phi constant +template +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR +T phi_v = _IsFloat(1.618033988749894848204586834365638L); + + +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR + double e = e_v; +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR + double log2e = log2e_v; +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR + double log10e = log10e_v; +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR + double pi = pi_v; +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR + double inv_pi = inv_pi_v; +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR + double inv_sqrtpi = inv_sqrtpi_v; +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR + double ln2 = ln2_v; +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR + double ln10 = ln10_v; +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR + double sqrt2 = sqrt2_v; +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR + double sqrt3 = sqrt3_v; +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR + double inv_sqrt3 = inv_sqrt3_v; +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR + double egamma = egamma_v; +_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR + double phi = phi_v; + +#endif //_LIBCPP_STD_VER > 17 + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif //_LIBCPP_NUMBERS 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 @@ -99,6 +99,7 @@ #endif #include #include +#include #include #include #include