|
Boost : |
From: Hamish Mackenzie (hamish_at_[hidden])
Date: 2005-10-19 14:04:23
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.
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;
}
You might use it like this...
std::vector< int * > x1;
std::vector< optional< int > > x2;
...
int default_value = 5;
// I imagine this currently fails due to ( x == none )
std::transform( x1.begin(), x1.end(), x1.begin(),
fill( _1, default_value ) );
// And this probably fails due to x = &default_value
std::transform( x2.begin(), x2.end(), x2.begin(),
fill( _1, default_value ) );
I am not using this as an argument against the use of * and ->. I was
just wondering if we could make the above (or something similar) work.
Hamish
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk