1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #ifndef BOOST_OUTCOME_TRAIT_STD_EXCEPTION_HPP
- #define BOOST_OUTCOME_TRAIT_STD_EXCEPTION_HPP
- #include "../config.hpp"
- #include <exception>
- BOOST_OUTCOME_V2_NAMESPACE_BEGIN
- namespace policy
- {
- namespace detail
- {
-
- inline std::exception_ptr make_exception_ptr(std::exception_ptr v) { return v; }
-
- template <class T> constexpr inline decltype(auto) exception_ptr(T &&v) { return make_exception_ptr(std::forward<T>(v)); }
- }
-
- template <class T> constexpr inline decltype(auto) exception_ptr(T &&v) { return detail::exception_ptr(std::forward<T>(v)); }
- namespace detail
- {
- template <bool has_error_payload> struct _rethrow_exception
- {
- template <class Exception> explicit _rethrow_exception(Exception && /*unused*/) // NOLINT
- {
- }
- };
- template <> struct _rethrow_exception<true>
- {
- template <class Exception> explicit _rethrow_exception(Exception &&excpt) // NOLINT
- {
-
- rethrow_exception(policy::exception_ptr(std::forward<Exception>(excpt)));
- }
- };
- }
- }
- namespace trait
- {
- namespace detail
- {
-
- template <> struct _is_exception_ptr_available<std::exception_ptr>
- {
- static constexpr bool value = true;
- using type = std::exception_ptr;
- };
- }
-
- template <> struct is_error_type<std::exception_ptr>
- {
- static constexpr bool value = true;
- };
- }
- BOOST_OUTCOME_V2_NAMESPACE_END
- #endif
|