no_exceptions_support.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef BOOST_CORE_NO_EXCEPTIONS_SUPPORT_HPP
  2. #define BOOST_CORE_NO_EXCEPTIONS_SUPPORT_HPP
  3. #if defined(_MSC_VER)
  4. # pragma once
  5. #endif
  6. //----------------------------------------------------------------------
  7. // (C) Copyright 2004 Pavel Vozenilek.
  8. // Use, modification and distribution is subject to the Boost Software
  9. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt
  10. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  11. //
  12. //
  13. // This file contains helper macros used when exception support may be
  14. // disabled (as indicated by macro BOOST_NO_EXCEPTIONS).
  15. //
  16. // Before picking up these macros you may consider using RAII techniques
  17. // to deal with exceptions - their syntax can be always the same with
  18. // or without exception support enabled.
  19. //----------------------------------------------------------------------
  20. #include <boost/config.hpp>
  21. #include <boost/config/workaround.hpp>
  22. #if !(defined BOOST_NO_EXCEPTIONS)
  23. # define BOOST_TRY { try
  24. # define BOOST_CATCH(x) catch(x)
  25. # define BOOST_RETHROW throw;
  26. # define BOOST_CATCH_END }
  27. #else
  28. # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  29. # define BOOST_TRY { if ("")
  30. # define BOOST_CATCH(x) else if (!"")
  31. # elif !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
  32. # define BOOST_TRY { if (true)
  33. # define BOOST_CATCH(x) else if (false)
  34. # else
  35. // warning C4127: conditional expression is constant
  36. # define BOOST_TRY { \
  37. __pragma(warning(push)) \
  38. __pragma(warning(disable: 4127)) \
  39. if (true) \
  40. __pragma(warning(pop))
  41. # define BOOST_CATCH(x) else \
  42. __pragma(warning(push)) \
  43. __pragma(warning(disable: 4127)) \
  44. if (false) \
  45. __pragma(warning(pop))
  46. # endif
  47. # define BOOST_RETHROW
  48. # define BOOST_CATCH_END }
  49. #endif
  50. #endif