no_exceptions_support.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef BOOST_DETAIL_NO_EXCEPTIONS_SUPPORT_HPP_
  2. #define BOOST_DETAIL_NO_EXCEPTIONS_SUPPORT_HPP_
  3. #if (defined _MSC_VER) && (_MSC_VER >= 1200)
  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. /* Example of use:
  21. void foo() {
  22. BOOST_TRY {
  23. ...
  24. } BOOST_CATCH(const std::bad_alloc&) {
  25. ...
  26. BOOST_RETHROW
  27. } BOOST_CATCH(const std::exception& e) {
  28. ...
  29. }
  30. BOOST_CATCH_END
  31. }
  32. With exception support enabled it will expand into:
  33. void foo() {
  34. { try {
  35. ...
  36. } catch (const std::bad_alloc&) {
  37. ...
  38. throw;
  39. } catch (const std::exception& e) {
  40. ...
  41. }
  42. }
  43. }
  44. With exception support disabled it will expand into:
  45. void foo() {
  46. { if(true) {
  47. ...
  48. } else if (false) {
  49. ...
  50. } else if (false) {
  51. ...
  52. }
  53. }
  54. }
  55. */
  56. //----------------------------------------------------------------------
  57. #include <boost/config.hpp>
  58. #include <boost/detail/workaround.hpp>
  59. #if !(defined BOOST_NO_EXCEPTIONS)
  60. # define BOOST_TRY { try
  61. # define BOOST_CATCH(x) catch(x)
  62. # define BOOST_RETHROW throw;
  63. # define BOOST_CATCH_END }
  64. #else
  65. # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  66. # define BOOST_TRY { if ("")
  67. # define BOOST_CATCH(x) else if (!"")
  68. # else
  69. # define BOOST_TRY { if (true)
  70. # define BOOST_CATCH(x) else if (false)
  71. # endif
  72. # define BOOST_RETHROW
  73. # define BOOST_CATCH_END }
  74. #endif
  75. #endif