
12 Mar
2006
12 Mar
'06
6:43 p.m.
On 3/12/06, Václav Veselý <vaclav.vesely@email.cz> wrote:
There is a common need of getting a value from an optional with possibility to define a default value in case of the optional is uninitialized. I suggest two alternatives:
optional<int> o; int i = o.get(123); // a meber function get with an additional parameter int j = from_optional(o, 123); // a free function
Both alternatives can be implemented simultaneously.
Hello, Is there any reason why you cannot do: optional<int> o; int i = o ? *o : 123; Regards, Mikael