Move the error value when throwing an exception in .value rval overloads (#62)

* Move the error value when throwing an exception in .value rval overloads
Fixes #61

* Bump version
This commit is contained in:
Simon Brand authored and GitHub committed 2019-07-10 09:26:02 +01:00
1 parent bcdc78bf8e
commit 6fe2af5191
2 files changed
+13 -4

No files matched your search

+3 -3
View File
@@ -18,7 +18,7 @@
#define TL_EXPECTED_VERSION_MAJOR 1
#define TL_EXPECTED_VERSION_MINOR 0
#define TL_EXPECTED_VERSION_PATCH 0
#define TL_EXPECTED_VERSION_PATCH 1
#include <exception>
#include <functional>
@@ -1907,14 +1907,14 @@ public:
detail::enable_if_t<!std::is_void<U>::value> * = nullptr>
TL_EXPECTED_11_CONSTEXPR const U &&value() const && {
if (!has_value())
detail::throw_exception(bad_expected_access<E>(err().value()));
detail::throw_exception(bad_expected_access<E>(std::move(err()).value()));
return std::move(val());
}
template <class U = T,
detail::enable_if_t<!std::is_void<U>::value> * = nullptr>
TL_EXPECTED_11_CONSTEXPR U &&value() && {
if (!has_value())
detail::throw_exception(bad_expected_access<E>(err().value()));
detail::throw_exception(bad_expected_access<E>(std::move(err()).value()));
return std::move(val());
}