N4015: A proposal to add a utility class to represent expected monad -- V. Escriba and P. Talbot

A new WG21 paper is available. A copy is linked below, and the paper will also appear in the next normal WG21 mailing. If you are not a committee member, please use the comments section below or the std-proposals forum for public discussion.

Document number: N4015

Date: 2014-05-20

A proposal to add a utility class to represent expected monad

by Vicente J. Botet Escriba and Pierre Talbot

Excerpt:

Class template expected<E,T> proposed here is a type that may contain a value of type T or a value of type E in its storage space. T represents the expected value, E represents the reason explaining why it doesn't contains a value of type T, that is the unexpected value. Its interface allows to query if the underlying value is either the expected value (of type T) or an unexpected value (of type E). The original idea comes from Andrei Alexandrescu C++ and Beyond 2012: Systematic Error Handling in C++ talk. The interface and the rational are based on std::optional N3793 and Haskell monads. We can consider that expected<E,T> is a generalization of optional<T> providing in addition a monad interface and some specific functions associated to the unexpected type E. It requires no changes to core language, and breaks no existing code.

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.