Le 18/05/2017 à 16:50, Peter Dimov via Boost a écrit :
Niall Douglas wrote:
I did consider returning optionals which might be empty instead of throwing an exception.
That's not what I was saying. I was saying that for result
, if you return by reference, you have to store an optional<T> object inside your result. But if you return by value, you don't have to store an optional and you can reuse your existing tag instead of adding the extra bool flag. That is, use variant instead of variant . Also applies to other possible combinations such as expected
E1>, E2>, ... Similarly, expected
, E2> can use a single variant for storage, if it can return by value. Return by reference requires it to have an actual expected object to which to bind the returned reference. Do you believe that these function should return by value in the general case or just for the nested expected?
Best, Vicente