no_exceptions_support.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Copyright 2004 - 2021 Pavel Vozenilek.
  3. // Copyright 2021 Matt Borland. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_MP_DETAIL_NO_EXCEPTIONS_SUPPORT_HPP
  7. #define BOOST_MP_DETAIL_NO_EXCEPTIONS_SUPPORT_HPP
  8. #include <boost/multiprecision/detail/standalone_config.hpp>
  9. #ifdef BOOST_MP_STANDALONE
  10. #ifndef BOOST_NO_EXCEPTIONS
  11. # define BOOST_MP_TRY { try
  12. # define BOOST_MP_CATCH(x) catch(x)
  13. # define BOOST_MP_RETHROW throw;
  14. # define BOOST_MP_CATCH_END }
  15. # define BOOST_MP_THROW_EXCEPTION(x) throw (x);
  16. #else
  17. # if !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
  18. # define BOOST_MP_TRY { if (true)
  19. # define BOOST_MP_CATCH(x) else if (false)
  20. # else
  21. // warning C4127: conditional expression is constant
  22. # define BOOST_MP_TRY { \
  23. __pragma(warning(push)) \
  24. __pragma(warning(disable: 4127)) \
  25. if (true) \
  26. __pragma(warning(pop))
  27. # define BOOST_MP_CATCH(x) else \
  28. __pragma(warning(push)) \
  29. __pragma(warning(disable: 4127)) \
  30. if (false) \
  31. __pragma(warning(pop))
  32. # endif
  33. # define BOOST_MP_RETHROW
  34. # define BOOST_MP_CATCH_END }
  35. # define BOOST_MP_THROW_EXCEPTION(x) {static_cast<void>(x);}
  36. #endif
  37. #else // Not standalone mode
  38. # include <boost/core/no_exceptions_support.hpp>
  39. # include <boost/throw_exception.hpp>
  40. # define BOOST_MP_TRY BOOST_TRY
  41. # define BOOST_MP_CATCH(x) BOOST_CATCH(x)
  42. # define BOOST_MP_RETHROW BOOST_RETHROW
  43. # define BOOST_MP_CATCH_END BOOST_CATCH_END
  44. # define BOOST_MP_THROW_EXCEPTION(x) BOOST_THROW_EXCEPTION(x)
  45. #endif // BOOST_MP_STANDALONE
  46. #endif // BOOST_MP_DETAIL_NO_EXCEPTIONS_SUPPORT_HPP