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 09:58:46
on Thu Sep 04 2008, Thorsten Ottosen <thorsten.ottosen-AT-dezide.com> wrote:
> 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?
It would increase the overall size because optional<T> needs to store a
bool as well as a T. It would work for any kind of iterator traversal
because the function object would need to be constructed on demand (you
have to do that even for forward iterators because you can't know that
the end iterator of a range isn't known by the user to be somewhere in a
larger range -- the user can always dereference it in that case), but
that extra check upon dereference would also increase cost. I am not
really convinced it's worthwhile.
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk