You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes it might he handy to drop the error, or maybe add an error, from previous expected/optional values, returns.
This may be also when needing to conform to an existing interface.
Not sure if these would be best methods or stand alone functions, but might be nicer methods, similar to the monadic methods.
template <class T>
class optional
{
public:
template < class E>
expected<T, E> to_expected(E&& error) const&;
template < class E>
expected<T, E> to_expected(E&& error) &&;
};
template <class T, class E>
class expected
{
public:
optional<T> to_optional() const&;
optional<T> to_optional() &&;
};
Would need overloads or use C++23 explicit this.
Alternative names as_optional, as_expected
Here are basic implementations of a stand alone functions which would work for now (might not be strictly correct/ideal in terms of move/forward rvalue ref etc), just to give basic idea.
Sometimes it might he handy to drop the error, or maybe add an error, from previous expected/optional values, returns.
This may be also when needing to conform to an existing interface.
Not sure if these would be best methods or stand alone functions, but might be nicer methods, similar to the monadic methods.
Would need overloads or use C++23 explicit this.
Alternative names
as_optional
,as_expected
Here are basic implementations of a stand alone functions which would work for now (might not be strictly correct/ideal in terms of move/forward rvalue ref etc), just to give basic idea.
The text was updated successfully, but these errors were encountered: