return hasException() && e_.is_compatible_with<Ex>();
}
- exception_wrapper& exception() {
+ exception_wrapper& exception() & {
if (!hasException()) {
try_detail::throwTryDoesNotContainException();
}
return e_;
}
- const exception_wrapper& exception() const {
+ exception_wrapper&& exception() && {
+ if (!hasException()) {
+ try_detail::throwTryDoesNotContainException();
+ }
+ return std::move(e_);
+ }
+
+ const exception_wrapper& exception() const & {
if (!hasException()) {
try_detail::throwTryDoesNotContainException();
}
return e_;
}
+ const exception_wrapper&& exception() const && {
+ if (!hasException()) {
+ try_detail::throwTryDoesNotContainException();
+ }
+ return std::move(e_);
+ }
+
/*
* @returns a pointer to the `std::exception` held by `*this`, if one is held;
* otherwise, returns `nullptr`.
*
* @returns mutable reference to the exception contained by this Try
*/
- exception_wrapper& exception() {
+ exception_wrapper& exception() & {
if (!hasException()) {
try_detail::throwTryDoesNotContainException();
}
return e_;
}
- const exception_wrapper& exception() const {
+ exception_wrapper&& exception() && {
+ if (!hasException()) {
+ try_detail::throwTryDoesNotContainException();
+ }
+ return std::move(e_);
+ }
+
+ const exception_wrapper& exception() const & {
if (!hasException()) {
try_detail::throwTryDoesNotContainException();
}
return e_;
}
+ const exception_wrapper&& exception() const && {
+ if (!hasException()) {
+ try_detail::throwTryDoesNotContainException();
+ }
+ return std::move(e_);
+ }
+
/*
* @returns a pointer to the `std::exception` held by `*this`, if one is held;
* otherwise, returns `nullptr`.