From d88ba98e92237bde7c04029ef77858c0031171b7 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 3 Jun 2017 15:51:28 +0300 Subject: [PATCH] Throw bad_expected_access if throw_on_unexpected returns --- include/boost/variant2/expected.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/boost/variant2/expected.hpp b/include/boost/variant2/expected.hpp index d7339bc..539b70e 100644 --- a/include/boost/variant2/expected.hpp +++ b/include/boost/variant2/expected.hpp @@ -90,9 +90,8 @@ public: // throw_on_unexpected -template void throw_on_unexpected( E const& e ) +template void throw_on_unexpected( E const& /*e*/ ) { - throw bad_expected_access( e ); } void throw_on_unexpected( std::error_code const & e ) @@ -137,7 +136,10 @@ private: } else { - throw_on_unexpected( get(v_) ); + auto const & e = get(v_); + + throw_on_unexpected( e ); + throw bad_expected_access>( e ); } }); }