fix doc example typo
[boost.git] / boost / throw_exception.hpp
blobda143393dbab06382570ecb7f84638be7a98164e
1 #ifndef BOOST_THROW_EXCEPTION_HPP_INCLUDED
2 #define BOOST_THROW_EXCEPTION_HPP_INCLUDED
4 // MS compatible compilers support #pragma once
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
7 # pragma once
8 #endif
11 // boost/throw_exception.hpp
13 // Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
14 // Copyright (c) 2008-2009 Emil Dotchevski and Reverge Studios, Inc.
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)
20 // http://www.boost.org/libs/utility/throw_exception.html
23 #include <boost/config.hpp>
24 #include <boost/detail/workaround.hpp>
25 #include <exception>
27 #if !defined( BOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x593) )
28 # define BOOST_EXCEPTION_DISABLE
29 #endif
31 #if !defined( BOOST_EXCEPTION_DISABLE ) && defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1310 )
32 # define BOOST_EXCEPTION_DISABLE
33 #endif
35 #if !defined( BOOST_EXCEPTION_DISABLE )
36 # include <boost/exception/exception.hpp>
37 # include <boost/current_function.hpp>
38 # define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(::boost::enable_error_info(x) <<\
39 ::boost::throw_function(BOOST_CURRENT_FUNCTION) <<\
40 ::boost::throw_file(__FILE__) <<\
41 ::boost::throw_line((int)__LINE__))
42 #else
43 # define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x)
44 #endif
46 namespace boost
49 #ifdef BOOST_NO_EXCEPTIONS
51 void throw_exception( std::exception const & e ); // user defined
53 #else
55 inline void throw_exception_assert_compatibility( std::exception const & ) { }
57 template<class E> inline void throw_exception( E const & e )
59 //All boost exceptions are required to derive std::exception,
60 //to ensure compatibility with BOOST_NO_EXCEPTIONS.
61 throw_exception_assert_compatibility(e);
63 #ifndef BOOST_EXCEPTION_DISABLE
64 throw enable_current_exception(enable_error_info(e));
65 #else
66 throw e;
67 #endif
70 #endif
72 } // namespace boost
74 #endif // #ifndef BOOST_THROW_EXCEPTION_HPP_INCLUDED