Add operator|=(result&, value)

This commit is contained in:
Peter Dimov
2024-02-01 06:40:47 +02:00
parent 2b14b9a96a
commit a9659f4318
4 changed files with 121 additions and 0 deletions
+17
View File
@@ -1067,6 +1067,23 @@ U operator|( result<void, E>&& r, F&& f )
}
}
// operator|=
// result |= value
template<class T, class E, class U,
class En = typename std::enable_if<detail::is_value_convertible_to<U, T>::value>::type
>
result<T, E>& operator|=( result<T, E>& r, U&& u )
{
if( !r )
{
r = std::forward<U>( u );
}
return r;
}
// operator&
// result & unary-returning-value