Skip to content

Commit

Permalink
Typos and disable example 9b for old Boost
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Kormanyos committed Jun 10, 2024
1 parent 9a72512 commit 69859d1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 78 deletions.
22 changes: 11 additions & 11 deletions examples/example009a_boost_math_standalone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,17 @@ auto ::math::wide_decimal::example009a_boost_math_standalone() -> bool
return result_is_ok;
}

#if defined(__clang__) && !defined(__APPLE__)
#pragma GCC diagnostic pop
#endif

#if defined(__GNUC__)
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#endif

#else

#if defined(WIDE_DECIMAL_NAMESPACE)
Expand Down Expand Up @@ -639,14 +650,3 @@ auto main() -> int // NOLINT(bugprone-exception-escape)
}

#endif

#if defined(__clang__) && !defined(__APPLE__)
#pragma GCC diagnostic pop
#endif

#if defined(__GNUC__)
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#endif
94 changes: 27 additions & 67 deletions examples/example009b_boost_math_standalone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,15 @@
#error BOOST_VERSION is not defined. Ensure that <boost/version.hpp> is properly included.
#endif

#if (BOOST_VERSION >= 108000)
#if (BOOST_VERSION >= 108300)

#if !defined(BOOST_NO_EXCEPTIONS)
#define BOOST_NO_EXCEPTIONS
#endif
#if !defined(BOOST_NO_RTTI)
#define BOOST_NO_RTTI
#endif
#endif

#if ((BOOST_VERSION >= 107700) && !defined(BOOST_MATH_STANDALONE))
#if (defined(_MSC_VER) && (_MSC_VER < 1920))
#else
#define BOOST_MATH_STANDALONE
#endif
#endif

#if ((BOOST_VERSION >= 107900) && !defined(BOOST_MP_STANDALONE))
#if !defined(BOOST_MP_STANDALONE)
#define BOOST_MP_STANDALONE
#endif

Expand All @@ -49,16 +41,15 @@
#pragma GCC diagnostic ignored "-Wdeprecated-copy"
#endif

#if (BOOST_VERSION < 107900)
#include <boost/math/policies/error_handling.hpp>
#include <boost/throw_exception.hpp>
#endif

#include <boost/math/bindings/decwide_t.hpp>
#include <boost/math/special_functions/gamma.hpp>

#endif

#include <examples/example_decwide_t.h>

#if (BOOST_VERSION >= 108300)

WIDE_DECIMAL_NAMESPACE_BEGIN

#if(__cplusplus >= 201703L)
Expand Down Expand Up @@ -405,18 +396,8 @@ auto ::math::wide_decimal::example009b_boost_math_standalone() -> bool
using wide_decimal_305_type = ::math::wide_decimal::decwide_t<static_cast<std::int32_t>(INT32_C(305)), std::uint32_t, void>;
#endif

#if (BOOST_VERSION < 107900)
using boost_wrapexcept_round_type = ::boost::wrapexcept<::boost::math::rounding_error>;
using boost_wrapexcept_domain_type = ::boost::wrapexcept<std::domain_error>;
#endif

auto result_is_ok = false;

#if (BOOST_VERSION >= 108000)
#else
try
{
#endif
const auto result_010_is_ok = example009b_boost::test_both<wide_decimal_010_type>();
const auto result_035_is_ok = example009b_boost::test_both<wide_decimal_035_type>();
const auto result_105_is_ok = example009b_boost::test_both<wide_decimal_105_type>();
Expand All @@ -426,43 +407,33 @@ auto ::math::wide_decimal::example009b_boost_math_standalone() -> bool
&& result_035_is_ok
&& result_105_is_ok
&& result_305_is_ok);
#if (BOOST_VERSION >= 108000)
#else
}
#if (BOOST_VERSION < 107900)
catch(const boost_wrapexcept_round_type& e)
{
result_is_ok = false;

std::cout << "Exception: boost_wrapexcept_round_type: " << e.what() << std::endl;
}
catch(const boost_wrapexcept_domain_type& e)
{
result_is_ok = false;
return result_is_ok;
}

std::cout << "Exception: boost_wrapexcept_domain_type: " << e.what() << std::endl;
}
#else
// LCOV_EXCL_START
catch(const ::boost::math::rounding_error& e)
{
result_is_ok = false;
#if defined(__clang__) && !defined(__APPLE__)
#pragma GCC diagnostic pop
#endif

std::cout << "Exception: ::boost::math::rounding_error: " << e.what() << std::endl;
}
catch(const std::domain_error& e)
{
result_is_ok = false;
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#endif

std::cout << "Exception: std::domain_error: " << e.what() << std::endl;
}
// LCOV_EXCL_STOP
#endif
#endif
#else

return result_is_ok;
#if defined(WIDE_DECIMAL_NAMESPACE)
auto WIDE_DECIMAL_NAMESPACE::math::wide_decimal::example009b_boost_math_standalone() -> bool
#else
auto ::math::wide_decimal::example009b_boost_math_standalone() -> bool
#endif
{
return true;
}

#endif
// Enable this if you would like to activate this main() as a standalone example.
#if defined(WIDE_DECIMAL_STANDALONE_EXAMPLE009B_BOOST_MATH_STANDALONE)

Expand All @@ -478,14 +449,3 @@ auto main() -> int // NOLINT(bugprone-exception-escape)
}

#endif

#if defined(__clang__) && !defined(__APPLE__)
#pragma GCC diagnostic pop
#endif

#if defined(__GNUC__)
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#endif

0 comments on commit 69859d1

Please sign in to comment.