|
Boost : |
From: Fernando Cacciola (fernando_cacciola_at_[hidden])
Date: 2005-10-24 12:11:09
Hamish Mackenzie wrote:
> On Wed, 2005-10-19 at 09:16 -0400, David Abrahams wrote:
>>> Do you think the "fill" example would be useful to fill missing
>>> values in vector< OptionalPointee >?
>>
>> Sorry, I don't understand.
>
> Sorry I was in a hurry and didn't describe what I was thinking better.
> Here is the example from the other email.
>
I get your point.
You're looking for general usages of the Nullable concept (I won't call it
OptionalPointee anymore).
I like that.
> template< typename OptionalPointee, typename Value_Type >
> Optional_Pointee fill( Optional_Pointee x, Value_Type & default_value
> ) {
> if( x == none )
> {
> x = &default_value; // Does this work with optionals?
> }
>
> return x;
> }
>
No, that doesn't work with optional<>.
Furthermore, this is a bad example.
In the usage example below, 'x1' would end up with several pointers to the
'default_value' object, while 'x2' would end up with several distinct copies
of 'default_value' wrapped inside optional<>.
But I like the idea of looking for usefull usages of the Nullable concept.
-- Fernando Cacciola SciSoft http://fcacciola.50webs.com/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk