Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize exception specification #822

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 76 additions & 75 deletions include/boost/math/cstdfloat/cstdfloat_cmath.hpp

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions include/boost/math/cstdfloat/cstdfloat_iostream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
#include <stdexcept>
#include <string>
#include <boost/math/tools/assert.hpp>
#include <boost/math/tools/nothrow.hpp>
#include <boost/math/tools/throw_exception.hpp>

// #if (0)
#if defined(__GNUC__)

// Forward declarations of quadruple-precision string functions.
extern "C" int quadmath_snprintf(char *str, size_t size, const char *format, ...) throw();
extern "C" boost::math::cstdfloat::detail::float_internal128_t strtoflt128(const char*, char **) throw();
extern "C" int quadmath_snprintf(char *str, size_t size, const char *format, ...) BOOST_MATH_NOTHROW;
extern "C" boost::math::cstdfloat::detail::float_internal128_t strtoflt128(const char*, char **) BOOST_MATH_NOTHROW;

namespace std
{
Expand Down
3 changes: 2 additions & 1 deletion include/boost/math/cstdfloat/cstdfloat_limits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#if defined(BOOST_CSTDFLOAT_HAS_INTERNAL_FLOAT128_T) && defined(BOOST_MATH_USE_FLOAT128) && !defined(BOOST_CSTDFLOAT_NO_LIBQUADMATH_SUPPORT)

#include <limits>
#include <boost/math/tools/nothrow.hpp>

// Define the name of the global quadruple-precision function to be used for
// calculating quiet_NaN() in the specialization of std::numeric_limits<>.
Expand All @@ -37,7 +38,7 @@
#endif

// Forward declaration of the quadruple-precision square root function.
extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_SQRT(boost::math::cstdfloat::detail::float_internal128_t) throw();
extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_SQRT(boost::math::cstdfloat::detail::float_internal128_t) BOOST_MATH_NOTHROW;

namespace std
{
Expand Down
27 changes: 27 additions & 0 deletions include/boost/math/tools/nothrow.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// (C) Copyright Antony Polukhin 2022.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_MATH_TOOLS_NOTHROW_HPP
#define BOOST_MATH_TOOLS_NOTHROW_HPP

#include <boost/math/tools/is_standalone.hpp>

#ifndef BOOST_MATH_STANDALONE

#include <boost/config.hpp>

#define BOOST_MATH_NOTHROW BOOST_NOEXCEPT_OR_NOTHROW

#else // Standalone mode - use noexcept or throw()

#if __cplusplus >= 201103L
#define BOOST_MATH_NOTHROW noexcept
#else
#define BOOST_MATH_NOTHROW throw()
#endif

#endif

#endif // BOOST_MATH_TOOLS_NOTHROW_HPP
64 changes: 32 additions & 32 deletions test/compile_test/std_real_concept_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ template<>
struct numeric_limits<boost::math::concepts::std_real_concept>
{
static const bool is_specialized = true;
static boost::math::concepts::std_real_concept min NULL_MACRO() throw();
static boost::math::concepts::std_real_concept max NULL_MACRO() throw();
static boost::math::concepts::std_real_concept min NULL_MACRO() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept max NULL_MACRO() BOOST_NOEXCEPT_OR_NOTHROW;
static const int digits = 24;
static const int digits10 = 6;
static const int max_digits10 = 9;
static const bool is_signed = true;
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = 2;
static boost::math::concepts::std_real_concept epsilon() throw();
static boost::math::concepts::std_real_concept round_error() throw();
static boost::math::concepts::std_real_concept epsilon() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept round_error() BOOST_NOEXCEPT_OR_NOTHROW;
static const int min_exponent = -125;
static const int min_exponent10 = -37;
static const int max_exponent = 128;
Expand All @@ -68,10 +68,10 @@ struct numeric_limits<boost::math::concepts::std_real_concept>
static const bool has_signaling_NaN = true;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
static boost::math::concepts::std_real_concept infinity() throw();
static boost::math::concepts::std_real_concept quiet_NaN() throw();
static boost::math::concepts::std_real_concept signaling_NaN() throw();
static boost::math::concepts::std_real_concept denorm_min() throw();
static boost::math::concepts::std_real_concept infinity() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept quiet_NaN() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept signaling_NaN() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept denorm_min() BOOST_NOEXCEPT_OR_NOTHROW;
static const bool is_iec559 = true;
static const bool is_bounded = false;
static const bool is_modulo = false;
Expand All @@ -87,17 +87,17 @@ template<>
struct numeric_limits<boost::math::concepts::std_real_concept>
{
static const bool is_specialized = true;
static boost::math::concepts::std_real_concept min NULL_MACRO() throw();
static boost::math::concepts::std_real_concept max NULL_MACRO() throw();
static boost::math::concepts::std_real_concept min NULL_MACRO() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept max NULL_MACRO() BOOST_NOEXCEPT_OR_NOTHROW;
static const int digits = 53;
static const int digits10 = 15;
static const int max_digits10 = 17;
static const bool is_signed = true;
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = 2;
static boost::math::concepts::std_real_concept epsilon() throw();
static boost::math::concepts::std_real_concept round_error() throw();
static boost::math::concepts::std_real_concept epsilon() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept round_error() BOOST_NOEXCEPT_OR_NOTHROW;
static const int min_exponent = -1021;
static const int min_exponent10 = -307;
static const int max_exponent = 1024;
Expand All @@ -107,10 +107,10 @@ struct numeric_limits<boost::math::concepts::std_real_concept>
static const bool has_signaling_NaN = true;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
static boost::math::concepts::std_real_concept infinity() throw();
static boost::math::concepts::std_real_concept quiet_NaN() throw();
static boost::math::concepts::std_real_concept signaling_NaN() throw();
static boost::math::concepts::std_real_concept denorm_min() throw();
static boost::math::concepts::std_real_concept infinity() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept quiet_NaN() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept signaling_NaN() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept denorm_min() BOOST_NOEXCEPT_OR_NOTHROW;
static const bool is_iec559 = true;
static const bool is_bounded = false;
static const bool is_modulo = false;
Expand All @@ -126,17 +126,17 @@ template<>
struct numeric_limits<boost::math::concepts::std_real_concept>
{
static const bool is_specialized = true;
static boost::math::concepts::std_real_concept min NULL_MACRO() throw();
static boost::math::concepts::std_real_concept max NULL_MACRO() throw();
static boost::math::concepts::std_real_concept min NULL_MACRO() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept max NULL_MACRO() BOOST_NOEXCEPT_OR_NOTHROW;
static const int digits = 64;
static const int digits10 = 18;
static const int max_digits10 = 22;
static const bool is_signed = true;
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = 2;
static boost::math::concepts::std_real_concept epsilon() throw();
static boost::math::concepts::std_real_concept round_error() throw();
static boost::math::concepts::std_real_concept epsilon() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept round_error() BOOST_NOEXCEPT_OR_NOTHROW;
static const int min_exponent = -16381;
static const int min_exponent10 = -4931;
static const int max_exponent = 16384;
Expand All @@ -146,10 +146,10 @@ struct numeric_limits<boost::math::concepts::std_real_concept>
static const bool has_signaling_NaN = true;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
static boost::math::concepts::std_real_concept infinity() throw();
static boost::math::concepts::std_real_concept quiet_NaN() throw();
static boost::math::concepts::std_real_concept signaling_NaN() throw();
static boost::math::concepts::std_real_concept denorm_min() throw();
static boost::math::concepts::std_real_concept infinity() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept quiet_NaN() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept signaling_NaN() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept denorm_min() BOOST_NOEXCEPT_OR_NOTHROW;
static const bool is_iec559 = true;
static const bool is_bounded = false;
static const bool is_modulo = false;
Expand All @@ -165,17 +165,17 @@ template<>
struct numeric_limits<boost::math::concepts::std_real_concept>
{
static const bool is_specialized = true;
static boost::math::concepts::std_real_concept min NULL_MACRO() throw();
static boost::math::concepts::std_real_concept max NULL_MACRO() throw();
static boost::math::concepts::std_real_concept min NULL_MACRO() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept max NULL_MACRO() BOOST_NOEXCEPT_OR_NOTHROW;
static const int digits = 113;
static const int digits10 = 33;
static const int max_digits10 = 37;
static const bool is_signed = true;
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = 2;
static boost::math::concepts::std_real_concept epsilon() throw();
static boost::math::concepts::std_real_concept round_error() throw();
static boost::math::concepts::std_real_concept epsilon() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept round_error() BOOST_NOEXCEPT_OR_NOTHROW;
static const int min_exponent = -16381;
static const int min_exponent10 = -4931;
static const int max_exponent = 16384;
Expand All @@ -185,10 +185,10 @@ struct numeric_limits<boost::math::concepts::std_real_concept>
static const bool has_signaling_NaN = true;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
static boost::math::concepts::std_real_concept infinity() throw();
static boost::math::concepts::std_real_concept quiet_NaN() throw();
static boost::math::concepts::std_real_concept signaling_NaN() throw();
static boost::math::concepts::std_real_concept denorm_min() throw();
static boost::math::concepts::std_real_concept infinity() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept quiet_NaN() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept signaling_NaN() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept denorm_min() BOOST_NOEXCEPT_OR_NOTHROW;
static const bool is_iec559 = true;
static const bool is_bounded = false;
static const bool is_modulo = false;
Expand Down
64 changes: 32 additions & 32 deletions test/std_real_concept_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ template<>
struct numeric_limits<boost::math::concepts::std_real_concept>
{
static const bool is_specialized = true;
static boost::math::concepts::std_real_concept min NULL_MACRO() throw();
static boost::math::concepts::std_real_concept max NULL_MACRO() throw();
static boost::math::concepts::std_real_concept min NULL_MACRO() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept max NULL_MACRO() BOOST_NOEXCEPT_OR_NOTHROW;
static const int digits = 24;
static const int digits10 = 6;
static const bool is_signed = true;
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = 2;
static boost::math::concepts::std_real_concept epsilon() throw();
static boost::math::concepts::std_real_concept round_error() throw();
static boost::math::concepts::std_real_concept epsilon() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept round_error() BOOST_NOEXCEPT_OR_NOTHROW;
static const int min_exponent = -125;
static const int min_exponent10 = -37;
static const int max_exponent = 128;
Expand All @@ -61,10 +61,10 @@ struct numeric_limits<boost::math::concepts::std_real_concept>
static const bool has_signaling_NaN = true;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
static boost::math::concepts::std_real_concept infinity() throw();
static boost::math::concepts::std_real_concept quiet_NaN() throw();
static boost::math::concepts::std_real_concept signaling_NaN() throw();
static boost::math::concepts::std_real_concept denorm_min() throw();
static boost::math::concepts::std_real_concept infinity() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept quiet_NaN() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept signaling_NaN() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept denorm_min() BOOST_NOEXCEPT_OR_NOTHROW;
static const bool is_iec559 = true;
static const bool is_bounded = false;
static const bool is_modulo = false;
Expand All @@ -80,16 +80,16 @@ template<>
struct numeric_limits<boost::math::concepts::std_real_concept>
{
static const bool is_specialized = true;
static boost::math::concepts::std_real_concept min NULL_MACRO() throw();
static boost::math::concepts::std_real_concept max NULL_MACRO() throw();
static boost::math::concepts::std_real_concept min NULL_MACRO() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept max NULL_MACRO() BOOST_NOEXCEPT_OR_NOTHROW;
static const int digits = 53;
static const int digits10 = 15;
static const bool is_signed = true;
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = 2;
static boost::math::concepts::std_real_concept epsilon() throw();
static boost::math::concepts::std_real_concept round_error() throw();
static boost::math::concepts::std_real_concept epsilon() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept round_error() BOOST_NOEXCEPT_OR_NOTHROW;
static const int min_exponent = -1021;
static const int min_exponent10 = -307;
static const int max_exponent = 1024;
Expand All @@ -99,10 +99,10 @@ struct numeric_limits<boost::math::concepts::std_real_concept>
static const bool has_signaling_NaN = true;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
static boost::math::concepts::std_real_concept infinity() throw();
static boost::math::concepts::std_real_concept quiet_NaN() throw();
static boost::math::concepts::std_real_concept signaling_NaN() throw();
static boost::math::concepts::std_real_concept denorm_min() throw();
static boost::math::concepts::std_real_concept infinity() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept quiet_NaN() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept signaling_NaN() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept denorm_min() BOOST_NOEXCEPT_OR_NOTHROW;
static const bool is_iec559 = true;
static const bool is_bounded = false;
static const bool is_modulo = false;
Expand All @@ -118,16 +118,16 @@ template<>
struct numeric_limits<boost::math::concepts::std_real_concept>
{
static const bool is_specialized = true;
static boost::math::concepts::std_real_concept min NULL_MACRO() throw();
static boost::math::concepts::std_real_concept max NULL_MACRO() throw();
static boost::math::concepts::std_real_concept min NULL_MACRO() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept max NULL_MACRO() BOOST_NOEXCEPT_OR_NOTHROW;
static const int digits = 64;
static const int digits10 = 18;
static const bool is_signed = true;
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = 2;
static boost::math::concepts::std_real_concept epsilon() throw();
static boost::math::concepts::std_real_concept round_error() throw();
static boost::math::concepts::std_real_concept epsilon() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept round_error() BOOST_NOEXCEPT_OR_NOTHROW;
static const int min_exponent = -16381;
static const int min_exponent10 = -4931;
static const int max_exponent = 16384;
Expand All @@ -137,10 +137,10 @@ struct numeric_limits<boost::math::concepts::std_real_concept>
static const bool has_signaling_NaN = true;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
static boost::math::concepts::std_real_concept infinity() throw();
static boost::math::concepts::std_real_concept quiet_NaN() throw();
static boost::math::concepts::std_real_concept signaling_NaN() throw();
static boost::math::concepts::std_real_concept denorm_min() throw();
static boost::math::concepts::std_real_concept infinity() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept quiet_NaN() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept signaling_NaN() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept denorm_min() BOOST_NOEXCEPT_OR_NOTHROW;
static const bool is_iec559 = true;
static const bool is_bounded = false;
static const bool is_modulo = false;
Expand All @@ -156,16 +156,16 @@ template<>
struct numeric_limits<boost::math::concepts::std_real_concept>
{
static const bool is_specialized = true;
static boost::math::concepts::std_real_concept min NULL_MACRO() throw();
static boost::math::concepts::std_real_concept max NULL_MACRO() throw();
static boost::math::concepts::std_real_concept min NULL_MACRO() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept max NULL_MACRO() BOOST_NOEXCEPT_OR_NOTHROW;
static const int digits = 113;
static const int digits10 = 33;
static const bool is_signed = true;
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = 2;
static boost::math::concepts::std_real_concept epsilon() throw();
static boost::math::concepts::std_real_concept round_error() throw();
static boost::math::concepts::std_real_concept epsilon() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept round_error() BOOST_NOEXCEPT_OR_NOTHROW;
static const int min_exponent = -16381;
static const int min_exponent10 = -4931;
static const int max_exponent = 16384;
Expand All @@ -175,10 +175,10 @@ struct numeric_limits<boost::math::concepts::std_real_concept>
static const bool has_signaling_NaN = true;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
static boost::math::concepts::std_real_concept infinity() throw();
static boost::math::concepts::std_real_concept quiet_NaN() throw();
static boost::math::concepts::std_real_concept signaling_NaN() throw();
static boost::math::concepts::std_real_concept denorm_min() throw();
static boost::math::concepts::std_real_concept infinity() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept quiet_NaN() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept signaling_NaN() BOOST_NOEXCEPT_OR_NOTHROW;
static boost::math::concepts::std_real_concept denorm_min() BOOST_NOEXCEPT_OR_NOTHROW;
static const bool is_iec559 = true;
static const bool is_bounded = false;
static const bool is_modulo = false;
Expand Down