25 May
2017
25 May
'17
10:38 p.m.
Ok. Now I am thinking, another thing you can do, is to internally store something like varient
but do not expose this Empty in the interface. Instead, rewrite observer functions like this: ``` bool has_value() const { if (BOOST_UNLIKELY(_is_in_empty_state())) __builtin_unreachable();
return _is_in_valued_state; } ```
Good god no. .has_value() is always legal to call irrespective of the current state. I don't mind the above for say .value(), so if trying to retrieve a value and the current state is not a value, that should be unreachable i.e. static analysis triggers if you're doing an obvious stupidity. Niall -- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/