From 8765ee198373eb3effa3c2a91860519e30cdd16e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 3 Jun 2017 00:12:01 +0300 Subject: [PATCH] Add expected::operator>> as an alias for .then --- include/boost/variant2/expected.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/boost/variant2/expected.hpp b/include/boost/variant2/expected.hpp index d2b6581..e490625 100644 --- a/include/boost/variant2/expected.hpp +++ b/include/boost/variant2/expected.hpp @@ -409,6 +409,18 @@ public: return unexpected(); } } + + template then_result operator>>( F && f ) const + { + if( has_value() ) + { + return std::forward(f)( **this ); + } + else + { + return unexpected(); + } + } }; template inline constexpr bool operator==( expected const & x1, expected const & x2 )