Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / contract / detail / exception.hpp
1
2 #ifndef BOOST_CONTRACT_DETAIL_EXCEPTION_HPP_
3 #define BOOST_CONTRACT_DETAIL_EXCEPTION_HPP_
4
5 // Copyright (C) 2008-2019 Lorenzo Caminiti
6 // Distributed under the Boost Software License, Version 1.0 (see accompanying
7 // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
8 // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
9
10 #include <boost/config.hpp>
11 #include <exception>
12
13 namespace boost { namespace contract { namespace detail {
14
15 // Using this instead of std::uncaught_exception() because
16 // std::uncaught_exception will be removed in C++20.
17 inline bool uncaught_exception() BOOST_NOEXCEPT {
18     // Alternatively, this could just return `boost::core::uncaught_exceptions()
19     // > 0` but that emulates the exception count which is not needed by this
20     // lib (the implementation below is simpler and could be faster).
21     #ifdef __cpp_lib_uncaught_exceptions
22         return std::uncaught_exceptions() > 0;
23     #else
24         return std::uncaught_exception();
25     #endif
26 }
27
28 } } } // namespace
29
30 #endif // #include guard
31