throw_exception.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #ifndef UUID_AA15E74A856F11E08B8D93F24824019B
  2. #define UUID_AA15E74A856F11E08B8D93F24824019B
  3. #if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
  4. #pragma GCC system_header
  5. #endif
  6. #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
  7. #pragma warning(push,1)
  8. #endif
  9. // MS compatible compilers support #pragma once
  10. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  11. # pragma once
  12. #endif
  13. //
  14. // boost/throw_exception.hpp
  15. //
  16. // Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
  17. // Copyright (c) 2008-2009 Emil Dotchevski and Reverge Stuccos, Inc.
  18. //
  19. // Distributed under the Boost Software License, Version 1.0. (See
  20. // accompanying file LICENSE_1_0.txt or copy at
  21. // http://www.boost.org/LICENSE_1_0.txt)
  22. //
  23. // http://www.boost.org/libs/utility/throw_exception.html
  24. //
  25. #include <boost/exception/detail/attribute_noreturn.hpp>
  26. #include <boost/detail/workaround.hpp>
  27. #include <boost/config.hpp>
  28. #include <exception>
  29. #if !defined( BOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x593) )
  30. # define BOOST_EXCEPTION_DISABLE
  31. #endif
  32. #if !defined( BOOST_EXCEPTION_DISABLE ) && defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1310 )
  33. # define BOOST_EXCEPTION_DISABLE
  34. #endif
  35. #if !defined( BOOST_EXCEPTION_DISABLE )
  36. # include <boost/exception/exception.hpp>
  37. #if !defined(BOOST_THROW_EXCEPTION_CURRENT_FUNCTION)
  38. # include <boost/current_function.hpp>
  39. # define BOOST_THROW_EXCEPTION_CURRENT_FUNCTION BOOST_CURRENT_FUNCTION
  40. #endif
  41. # define BOOST_THROW_EXCEPTION(x) ::boost::exception_detail::throw_exception_(x,BOOST_THROW_EXCEPTION_CURRENT_FUNCTION,__FILE__,__LINE__)
  42. #else
  43. # define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x)
  44. #endif
  45. namespace boost
  46. {
  47. #ifdef BOOST_NO_EXCEPTIONS
  48. void throw_exception( std::exception const & e ); // user defined
  49. #else
  50. inline void throw_exception_assert_compatibility( std::exception const & ) { }
  51. template<class E> BOOST_ATTRIBUTE_NORETURN inline void throw_exception( E const & e )
  52. {
  53. //All boost exceptions are required to derive from std::exception,
  54. //to ensure compatibility with BOOST_NO_EXCEPTIONS.
  55. throw_exception_assert_compatibility(e);
  56. #ifndef BOOST_EXCEPTION_DISABLE
  57. throw enable_current_exception(enable_error_info(e));
  58. #else
  59. throw e;
  60. #endif
  61. }
  62. #endif
  63. #if !defined( BOOST_EXCEPTION_DISABLE )
  64. namespace
  65. exception_detail
  66. {
  67. template <class E>
  68. BOOST_ATTRIBUTE_NORETURN
  69. void
  70. throw_exception_( E const & x, char const * current_function, char const * file, int line )
  71. {
  72. boost::throw_exception(
  73. set_info(
  74. set_info(
  75. set_info(
  76. enable_error_info(x),
  77. throw_function(current_function)),
  78. throw_file(file)),
  79. throw_line(line)));
  80. }
  81. }
  82. #endif
  83. } // namespace boost
  84. #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
  85. #pragma warning(pop)
  86. #endif
  87. #endif