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