On 16/05/2017 13:50, Peter Dimov wrote:
Surely this must also throw if f1_impl() can produce an error outcome and thus might not contain an X?
Yes of course, the examples are deliberately identical semantically, one uses "void get()" and the other uses "T value()". I prefer the second.
Future uses "T get()". This is established standard. Smart pointers use "T* get()", which is equivalent to the above. Also standard. Boost Optional uses "T& get()" (although also provides value(), presumably for standard compatibility). Std Optional uses "T value()". This is either still experimental or approved for C++17; I'm not entirely sure how far along that is. The different interfaces of the above seem unfortunate (and Std Optional seems incorrect in this regard to me). So why not "T get()"? That's much more consistent with other types.