throw_exception.hpp 2.9 KB

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