Let me just recall her the suggestion from Peter made in the other thread. Mybe have two types: `expected<T, E>` does not have the empty state or default constructor -- it is used as function's return type `prepare_expected<T, E>` is either T or E or Empty -- you use it inside function to build expected<T, E>:
``` expected<T, E> f() { prepare_expected<T, E> ans; // populate (or not) ans return ans; // in this conversion you can do all sorts of checks } ```
When it comes to converting from `prepare_expected<T, E>` to `expected<T, E>`, you have plenty of choices: require manual conversion, narrow-contract to be checked, a defensive if and throw... I am just not sure if performance can be negatively impacted with this.
I originally considered this design for Outcome's API. I ended up rejecting it because it's superfluous if you have correctly designed your expected/outcome/whatever in the first place. Niall -- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/