Boost logo

Boost :

From: Andrey Semashev (andysem_at_[hidden])
Date: 2008-04-11 15:14:46


Fernando Cacciola wrote:
> Hi Andrey,
>
>> Your behavior can be implemented in a non-intrusive way something like
>> that:
>>
>> template< typename T >
>> void force_koenig_swap(optional< T >& left, optional< T >& right)
>> {
>> bool left_empty = !left;
>> if (left_empty) left = in_place();
>> bool right_empty = !right;
>> if (right_empty) right = in_place();
>>
>> using std::swap;
>> swap(left.get(), right.get());
>>
>> if (left_empty) right = none;
>> if (right_empty) left = none;
>> }
>>
> But isn't that, syntax aside, *exactly* the same Thorsten proposed?? I can't
> tell the difference...

The only difference is that it's not intrusive.


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