forked from boostorg/system
Fix rvalue result<void> cases
This commit is contained in:
@ -1029,6 +1029,23 @@ template<class E, class F,
|
||||
}
|
||||
}
|
||||
|
||||
template<class E, class F,
|
||||
class U = decltype( std::declval<F>()() ),
|
||||
class En1 = typename std::enable_if<detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<std::is_void<typename U::value_type>::value>::type
|
||||
>
|
||||
U operator|( result<void, E>&& r, F&& f )
|
||||
{
|
||||
if( r )
|
||||
{
|
||||
return {};
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<F>( f )();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
|
@ -335,5 +335,25 @@ int main()
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E> r2 = result<void>() | fv;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E> r2 = result<void>() | fv2;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E> r2 = result<void>( in_place_error ) | fv;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E> r2 = result<void>( in_place_error ) | fv2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
Reference in New Issue
Block a user