The contents of the Special Functions IS were added to the C++17 draft, so this enables them by default for C++17.
* include/bits/c++config (_GLIBCXX_USE_STD_SPEC_FUNCS): Define for C++17, or for C++11/C++14 when __STDCPP_WANT_MATH_SPEC_FUNCS__ is true. * include/bits/specfun.h [!__STDCPP_WANT_MATH_SPEC_FUNCS__]: Don't do #error for C++17. * include/c_global/cmath: Check _GLIBCXX_USE_STD_SPEC_FUNCS instead of __STDCPP_WANT_MATH_SPEC_FUNCS__. * include/tr1/bessel_function.tcc: Likewise. * include/tr1/beta_function.tcc: Likewise. * include/tr1/cmath: Likewise. * include/tr1/ell_integral.tcc: Likewise. * include/tr1/exp_integral.tcc: Likewise. * include/tr1/gamma.tcc: Likewise. * include/tr1/hypergeometric.tcc: Likewise. * include/tr1/legendre_function.tcc: Likewise. * include/tr1/modified_bessel_func.tcc: Likewise. * include/tr1/poly_hermite.tcc: Likewise. * include/tr1/poly_laguerre.tcc: Likewise. * include/tr1/riemann_zeta.tcc: Likewise. * include/tr1/special_function_util.h: Likewise. * testsuite/26_numerics/headers/cmath/functions_std_c++17.cc: New. Tested x86_64-linux and powerpc64-linux, committed to trunk.
commit b2a59e048c1f125c4876229743bbb9d5475c4b8f Author: Jonathan Wakely <jwak...@redhat.com> Date: Tue Aug 2 16:09:50 2016 +0100 Enable Mathematical Special Functions for C++17 * include/bits/c++config (_GLIBCXX_USE_STD_SPEC_FUNCS): Define for C++17, or for C++11/C++14 when __STDCPP_WANT_MATH_SPEC_FUNCS__ is true. * include/bits/specfun.h [!__STDCPP_WANT_MATH_SPEC_FUNCS__]: Don't do #error for C++17. * include/c_global/cmath: Check _GLIBCXX_USE_STD_SPEC_FUNCS instead of __STDCPP_WANT_MATH_SPEC_FUNCS__. * include/tr1/bessel_function.tcc: Likewise. * include/tr1/beta_function.tcc: Likewise. * include/tr1/cmath: Likewise. * include/tr1/ell_integral.tcc: Likewise. * include/tr1/exp_integral.tcc: Likewise. * include/tr1/gamma.tcc: Likewise. * include/tr1/hypergeometric.tcc: Likewise. * include/tr1/legendre_function.tcc: Likewise. * include/tr1/modified_bessel_func.tcc: Likewise. * include/tr1/poly_hermite.tcc: Likewise. * include/tr1/poly_laguerre.tcc: Likewise. * include/tr1/riemann_zeta.tcc: Likewise. * include/tr1/special_function_util.h: Likewise. * testsuite/26_numerics/headers/cmath/functions_std_c++17.cc: New. diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index 4625607..8d2c361 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -532,6 +532,13 @@ namespace std #define _GLIBCXX_TXN_SAFE_DYN #endif +#if __cplusplus > 201402L +// In C++17 mathematical special functions are in namespace std. +# define _GLIBCXX_USE_STD_SPEC_FUNCS 1 +#elif __cplusplus >= 201103L && __STDCPP_WANT_MATH_SPEC_FUNCS__ != 0 +// For C++11 and C++14 they are in namespace std when requested. +# define _GLIBCXX_USE_STD_SPEC_FUNCS 1 +#endif // The remainder of the prewritten config is automatic; all the // user hooks are listed above. diff --git a/libstdc++-v3/include/bits/specfun.h b/libstdc++-v3/include/bits/specfun.h index 9f7bb87..93e1852 100644 --- a/libstdc++-v3/include/bits/specfun.h +++ b/libstdc++-v3/include/bits/specfun.h @@ -38,7 +38,7 @@ #define __cpp_lib_math_special_functions 201603L -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ == 0 +#if __cplusplus <= 201403L && __STDCPP_WANT_MATH_SPEC_FUNCS__ == 0 # error include <cmath> and define __STDCPP_WANT_MATH_SPEC_FUNCS__ #endif diff --git a/libstdc++-v3/include/c_global/cmath b/libstdc++-v3/include/c_global/cmath index 6a24ebf..6db9dee 100644 --- a/libstdc++-v3/include/c_global/cmath +++ b/libstdc++-v3/include/c_global/cmath @@ -1790,7 +1790,7 @@ _GLIBCXX_END_NAMESPACE_VERSION #endif // C++11 -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ == 1 +#if _GLIBCXX_USE_STD_SPEC_FUNCS # include <bits/specfun.h> #endif diff --git a/libstdc++-v3/include/tr1/bessel_function.tcc b/libstdc++-v3/include/tr1/bessel_function.tcc index a2655d8..692f6da 100644 --- a/libstdc++-v3/include/tr1/bessel_function.tcc +++ b/libstdc++-v3/include/tr1/bessel_function.tcc @@ -50,7 +50,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS # define _GLIBCXX_MATH_NS ::std #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 @@ -630,7 +630,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail #undef _GLIBCXX_MATH_NS -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/beta_function.tcc b/libstdc++-v3/include/tr1/beta_function.tcc index 76f5093..34b22d4 100644 --- a/libstdc++-v3/include/tr1/beta_function.tcc +++ b/libstdc++-v3/include/tr1/beta_function.tcc @@ -48,7 +48,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS # define _GLIBCXX_MATH_NS ::std #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 @@ -199,7 +199,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail #undef _GLIBCXX_MATH_NS -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/cmath b/libstdc++-v3/include/tr1/cmath index 48466a0..7f77a2b 100644 --- a/libstdc++-v3/include/tr1/cmath +++ b/libstdc++-v3/include/tr1/cmath @@ -1141,7 +1141,7 @@ _GLIBCXX_END_NAMESPACE_VERSION } } -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS namespace std _GLIBCXX_VISIBILITY(default) { @@ -1254,7 +1254,7 @@ _GLIBCXX_END_NAMESPACE_VERSION } } -#else // ! __STDCPP_WANT_MATH_SPEC_FUNCS__ +#else // ! _GLIBCXX_USE_STD_SPEC_FUNCS #include <bits/stl_algobase.h> #include <limits> @@ -1683,6 +1683,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION } } -#endif // __STDCPP_WANT_MATH_SPEC_FUNCS__ +#endif // _GLIBCXX_USE_STD_SPEC_FUNCS #endif // _GLIBCXX_TR1_CMATH diff --git a/libstdc++-v3/include/tr1/ell_integral.tcc b/libstdc++-v3/include/tr1/ell_integral.tcc index 9a60ba3..c7bfe16 100644 --- a/libstdc++-v3/include/tr1/ell_integral.tcc +++ b/libstdc++-v3/include/tr1/ell_integral.tcc @@ -44,7 +44,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 { @@ -748,7 +748,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/exp_integral.tcc b/libstdc++-v3/include/tr1/exp_integral.tcc index ee7cdad..f5b3094 100644 --- a/libstdc++-v3/include/tr1/exp_integral.tcc +++ b/libstdc++-v3/include/tr1/exp_integral.tcc @@ -49,7 +49,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 { @@ -525,7 +525,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/gamma.tcc b/libstdc++-v3/include/tr1/gamma.tcc index 2c84b75..3eb7845 100644 --- a/libstdc++-v3/include/tr1/gamma.tcc +++ b/libstdc++-v3/include/tr1/gamma.tcc @@ -50,7 +50,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS # define _GLIBCXX_MATH_NS ::std #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 @@ -470,7 +470,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail #undef _GLIBCXX_MATH_NS -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } // namespace std diff --git a/libstdc++-v3/include/tr1/hypergeometric.tcc b/libstdc++-v3/include/tr1/hypergeometric.tcc index 77fb78d0..1c46f4a 100644 --- a/libstdc++-v3/include/tr1/hypergeometric.tcc +++ b/libstdc++-v3/include/tr1/hypergeometric.tcc @@ -43,7 +43,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS # define _GLIBCXX_MATH_NS ::std #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 @@ -777,7 +777,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail #undef _GLIBCXX_MATH_NS -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/legendre_function.tcc b/libstdc++-v3/include/tr1/legendre_function.tcc index d5f2022..1980ebb 100644 --- a/libstdc++-v3/include/tr1/legendre_function.tcc +++ b/libstdc++-v3/include/tr1/legendre_function.tcc @@ -48,7 +48,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS # define _GLIBCXX_MATH_NS ::std #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 @@ -305,7 +305,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail #undef _GLIBCXX_MATH_NS -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/modified_bessel_func.tcc b/libstdc++-v3/include/tr1/modified_bessel_func.tcc index 0162727..5278fb2 100644 --- a/libstdc++-v3/include/tr1/modified_bessel_func.tcc +++ b/libstdc++-v3/include/tr1/modified_bessel_func.tcc @@ -50,7 +50,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 { @@ -433,7 +433,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/poly_hermite.tcc b/libstdc++-v3/include/tr1/poly_hermite.tcc index a5a6bcb..7123e11 100644 --- a/libstdc++-v3/include/tr1/poly_hermite.tcc +++ b/libstdc++-v3/include/tr1/poly_hermite.tcc @@ -41,7 +41,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 { @@ -123,7 +123,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/poly_laguerre.tcc b/libstdc++-v3/include/tr1/poly_laguerre.tcc index 6c757e4..a51d1dc 100644 --- a/libstdc++-v3/include/tr1/poly_laguerre.tcc +++ b/libstdc++-v3/include/tr1/poly_laguerre.tcc @@ -43,7 +43,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS # define _GLIBCXX_MATH_NS ::std #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 @@ -321,7 +321,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail #undef _GLIBCXX_MATH_NS -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/riemann_zeta.tcc b/libstdc++-v3/include/tr1/riemann_zeta.tcc index f411b20..714bf9f 100644 --- a/libstdc++-v3/include/tr1/riemann_zeta.tcc +++ b/libstdc++-v3/include/tr1/riemann_zeta.tcc @@ -46,7 +46,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS # define _GLIBCXX_MATH_NS ::std #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 @@ -435,7 +435,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail #undef _GLIBCXX_MATH_NS -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/special_function_util.h b/libstdc++-v3/include/tr1/special_function_util.h index 2b8cf37..93f09ce 100644 --- a/libstdc++-v3/include/tr1/special_function_util.h +++ b/libstdc++-v3/include/tr1/special_function_util.h @@ -38,7 +38,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 { @@ -133,7 +133,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++17.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++17.cc new file mode 100644 index 0000000..481b659 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++17.cc @@ -0,0 +1,111 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++17" } +// { dg-do compile } + +#include <cmath> + +namespace gnu +{ + using std::acos; + using std::asin; + using std::atan; + using std::atan2; + using std::ceil; + using std::cos; + using std::cosh; + using std::exp; + using std::fabs; + using std::floor; + using std::fmod; + using std::frexp; + using std::ldexp; + using std::log; + using std::log10; + using std::modf; + using std::pow; + using std::sin; + using std::sinh; + using std::sqrt; + using std::tan; + using std::tanh; + + using std::assoc_laguerre; + using std::assoc_laguerref; + using std::assoc_laguerrel; + using std::assoc_legendre; + using std::assoc_legendref; + using std::assoc_legendrel; + using std::beta; + using std::betaf; + using std::betal; + using std::comp_ellint_1; + using std::comp_ellint_1f; + using std::comp_ellint_1l; + using std::comp_ellint_2; + using std::comp_ellint_2f; + using std::comp_ellint_2l; + using std::comp_ellint_3; + using std::comp_ellint_3f; + using std::comp_ellint_3l; + using std::cyl_bessel_i; + using std::cyl_bessel_if; + using std::cyl_bessel_il; + using std::cyl_bessel_j; + using std::cyl_bessel_jf; + using std::cyl_bessel_jl; + using std::cyl_bessel_k; + using std::cyl_bessel_kf; + using std::cyl_bessel_kl; + using std::cyl_neumann; + using std::cyl_neumannf; + using std::cyl_neumannl; + using std::ellint_1; + using std::ellint_1f; + using std::ellint_1l; + using std::ellint_2; + using std::ellint_2f; + using std::ellint_2l; + using std::ellint_3; + using std::ellint_3f; + using std::ellint_3l; + using std::expint; + using std::expintf; + using std::expintl; + using std::hermite; + using std::hermitef; + using std::hermitel; + using std::laguerre; + using std::laguerref; + using std::laguerrel; + using std::legendre; + using std::legendref; + using std::legendrel; + using std::riemann_zeta; + using std::riemann_zetaf; + using std::riemann_zetal; + using std::sph_bessel; + using std::sph_besself; + using std::sph_bessell; + using std::sph_legendre; + using std::sph_legendref; + using std::sph_legendrel; + using std::sph_neumann; + using std::sph_neumannf; + using std::sph_neumannl; +}