1 | // |
2 | // detail/throw_exception.hpp |
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
4 | // |
5 | // Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) |
6 | // |
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
9 | // |
10 | |
11 | #ifndef BOOST_ASIO_DETAIL_THROW_EXCEPTION_HPP |
12 | #define BOOST_ASIO_DETAIL_THROW_EXCEPTION_HPP |
13 | |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) |
15 | # pragma once |
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) |
17 | |
18 | #include <boost/asio/detail/config.hpp> |
19 | |
20 | #if defined(BOOST_ASIO_HAS_BOOST_THROW_EXCEPTION) |
21 | # include <boost/throw_exception.hpp> |
22 | #endif // defined(BOOST_ASIO_BOOST_THROW_EXCEPTION) |
23 | |
24 | namespace boost { |
25 | namespace asio { |
26 | namespace detail { |
27 | |
28 | #if defined(BOOST_ASIO_HAS_BOOST_THROW_EXCEPTION) |
29 | using boost::throw_exception; |
30 | #else // defined(BOOST_ASIO_HAS_BOOST_THROW_EXCEPTION) |
31 | |
32 | // Declare the throw_exception function for all targets. |
33 | template <typename Exception> |
34 | void throw_exception( |
35 | const Exception& e |
36 | BOOST_ASIO_SOURCE_LOCATION_DEFAULTED_PARAM); |
37 | |
38 | // Only define the throw_exception function when exceptions are enabled. |
39 | // Otherwise, it is up to the application to provide a definition of this |
40 | // function. |
41 | # if !defined(BOOST_ASIO_NO_EXCEPTIONS) |
42 | template <typename Exception> |
43 | void throw_exception( |
44 | const Exception& e |
45 | BOOST_ASIO_SOURCE_LOCATION_PARAM) |
46 | { |
47 | throw e; |
48 | } |
49 | # endif // !defined(BOOST_ASIO_NO_EXCEPTIONS) |
50 | |
51 | #endif // defined(BOOST_ASIO_HAS_BOOST_THROW_EXCEPTION) |
52 | |
53 | } // namespace detail |
54 | } // namespace asio |
55 | } // namespace boost |
56 | |
57 | #endif // BOOST_ASIO_DETAIL_THROW_EXCEPTION_HPP |
58 | |