Boost logo

Boost :

Subject: Re: [boost] [iterator] could non-small predicates/functors be stored as boost::optional<T> to avoid double construction?
From: David Abrahams (dave_at_[hidden])
Date: 2008-09-04 15:07:45

on Thu Sep 04 2008, "Giovanni Piero Deretta" <> wrote:

> On Thu, Sep 4, 2008 at 8:18 PM, Thorsten Ottosen
> <thorsten.ottosen_at_[hidden]> wrote:
>> David Abrahams skrev:
>>> on Thu Sep 04 2008, Thorsten Ottosen <>
>>> wrote:
>>>> Arno Schödl skrev:
>>>>>> Hi,
>>>>>> The headline pretty much says it all. Take transform iterator. When the
>>>>>> predicate is not trivial, we also have a redundant construction of the
>>>>>> object
>>>>>> in the end iterator. Maybe that could be removed?
>>>>>> best regards
>>>>>> -Thorsten
>>>>> I guess that would be restricted to forward iterators.
>>>> This has nothing to do with the wrapped iterator's type. A transform
>>>> iterator
>>>> currently stores a functor by value in addition to the wrapped iterator.
>>> Have you forgotten
>>> *--end
>> Yes. Sorry for the noise.
> 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.

Dave Abrahams
BoostPro Computing

Boost list run by bdawes at, gregod at, cpdaniel at, john at