On 19/05/2017 11:11, Niall Douglas wrote:
2. .ensure(empty|value|error|exception) will perform the default actions of calling the observer function for that state, but not return that state.
Weak yes. - I am not sure why you need this fancy syntax.
The constexpr variables are already there. So basically do we prefer:
1. .ensure_empty(), .ensure_value(), .ensure_error() and .ensure_exception()
2. Or .ensure(empty), .ensure(value), .ensure(error) and .ensure(exception)
I figure the latter looked nicer. It's same difference to the compiler, simple overload matching is constant time.
But why have them at all, rather than just calling value(), error(), etc and discarding the return value? They're also constexpr. Also, what code patterns would lead to wanting to do that frequently anyway? Given that the whole point is to transport a value or an error, it seems odd to have code paths that want to throw if a value or error was not produced but then not actually care what the "right" thing was.