Boost logo

Boost :

From: Pavel Vozenilek (pavel_vozenilek_at_[hidden])
Date: 2006-03-13 05:45:24


"Ulrich Eckhardt" wrote:

> 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
>
Also, they don't provide much advantage to the ternary operator
  int i = o ? *o : 123;

optional<int> foo () { ... expensive, returns empty optional on error .... }

optional<int result = from_optional(foo(), 123);

The names could be safe_get()
and optional_with_default().

/Pavel


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk