2 #ifndef BOOST_CONTRACT_DETAIL_EXCEPTION_HPP_
3 #define BOOST_CONTRACT_DETAIL_EXCEPTION_HPP_
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
10 #include <boost/config.hpp>
13 namespace boost { namespace contract { namespace detail {
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;
24 return std::uncaught_exception();
30 #endif // #include guard