Boost logo

Boost :

Subject: Re: [boost] [iterator] could non-small predicates/functors be stored as boost::optional<T> to avoid double construction?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-09-04 15:32:29


AMDG

David Abrahams wrote:
>> There is still some value in storing functors in optional<T>:
>> boost.lambda expressions are not asignable, thus rendering any
>> iterator that contains a lambda does no longer meet the requirements
>> of Assignable of which TrivialIterator is a refinement of.
>>
>> It is easy to add a wrapper around optional<T> that makes it
>> Assignable as long as T is copy constructible (which lambdas are), so
>> it can be used as a quick workaround for this problem.
>>
>
> But for that you wouldn't need the bool in optional.
>

I think that you do need it, actually.
I assume that assignment would be implemented with destroy + reconstruct?
In this case, you need to deal with the possibility of the copy
constructor throwing.

In Christ,
Steven Watanabe


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