Provide a new class template `attempt`

The new class encapsulates the result of a computation that may succeed or
fail. It is useful to encapsulate the result passed to callback functions.