mirror of
https://github.com/TartanLlama/expected.git
synced 2025-08-03 19:04:29 +02:00
Fix #15
This commit is contained in:
@@ -184,6 +184,19 @@ static constexpr unexpect_t unexpect{};
|
|||||||
|
|
||||||
/// \exclude
|
/// \exclude
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
template<typename E>
|
||||||
|
[[noreturn]] constexpr void throw_exception(E &&e) {
|
||||||
|
#if defined(__EXCEPTIONS) || defined(_CPPUNWIND)
|
||||||
|
throw std::forward<E>(e);
|
||||||
|
#else
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
__assume(0);
|
||||||
|
#else
|
||||||
|
__builtin_unreachable();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef TL_TRAITS_MUTEX
|
#ifndef TL_TRAITS_MUTEX
|
||||||
#define TL_TRAITS_MUTEX
|
#define TL_TRAITS_MUTEX
|
||||||
// C++14-style aliases for brevity
|
// C++14-style aliases for brevity
|
||||||
@@ -1729,7 +1742,7 @@ public:
|
|||||||
detail::enable_if_t<!std::is_void<U>::value> * = nullptr>
|
detail::enable_if_t<!std::is_void<U>::value> * = nullptr>
|
||||||
TL_EXPECTED_11_CONSTEXPR const U &value() const & {
|
TL_EXPECTED_11_CONSTEXPR const U &value() const & {
|
||||||
if (!has_value())
|
if (!has_value())
|
||||||
throw bad_expected_access<E>(err().value());
|
detail::throw_exception(bad_expected_access<E>(err().value()));
|
||||||
return val();
|
return val();
|
||||||
}
|
}
|
||||||
/// \group value
|
/// \group value
|
||||||
@@ -1737,7 +1750,7 @@ public:
|
|||||||
detail::enable_if_t<!std::is_void<U>::value> * = nullptr>
|
detail::enable_if_t<!std::is_void<U>::value> * = nullptr>
|
||||||
TL_EXPECTED_11_CONSTEXPR U &value() & {
|
TL_EXPECTED_11_CONSTEXPR U &value() & {
|
||||||
if (!has_value())
|
if (!has_value())
|
||||||
throw bad_expected_access<E>(err().value());
|
detail::throw_exception(bad_expected_access<E>(err().value()));
|
||||||
return val();
|
return val();
|
||||||
}
|
}
|
||||||
/// \group value
|
/// \group value
|
||||||
@@ -1745,7 +1758,7 @@ public:
|
|||||||
detail::enable_if_t<!std::is_void<U>::value> * = nullptr>
|
detail::enable_if_t<!std::is_void<U>::value> * = nullptr>
|
||||||
TL_EXPECTED_11_CONSTEXPR const U &&value() const && {
|
TL_EXPECTED_11_CONSTEXPR const U &&value() const && {
|
||||||
if (!has_value())
|
if (!has_value())
|
||||||
throw bad_expected_access<E>(err().value());
|
detail::throw_exception(bad_expected_access<E>(err().value()));
|
||||||
return std::move(val());
|
return std::move(val());
|
||||||
}
|
}
|
||||||
/// \group value
|
/// \group value
|
||||||
@@ -1753,7 +1766,7 @@ public:
|
|||||||
detail::enable_if_t<!std::is_void<U>::value> * = nullptr>
|
detail::enable_if_t<!std::is_void<U>::value> * = nullptr>
|
||||||
TL_EXPECTED_11_CONSTEXPR U &&value() && {
|
TL_EXPECTED_11_CONSTEXPR U &&value() && {
|
||||||
if (!has_value())
|
if (!has_value())
|
||||||
throw bad_expected_access<E>(err().value());
|
detail::throw_exception(bad_expected_access<E>(err().value()));
|
||||||
return std::move(val());
|
return std::move(val());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user