Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-01-09 11:45:39


hartmutkaiser_at_[hidden] (Hartmut Kaiser) writes:

> David Abrahams wrote:
>
>> > You're right, but IMHO this is a complete different situation. The
>> > iterator adaptor constructor copies the iterator parameter
>> anyway into
>> > the own m_iterator member, so further working of the
>> iterator_adaptor
>> > does not rely on a reference as would do the algorithms, if they'd
>> > take references. Taking the iterator parameter by const reference
>> > simply would avoid one additional copy operation, which may
>> be costly for more complex iterators.
>>
>> The only thing that gives me pause are Andrei's findings here:
>>
>> http://thread.gmane.org/gmane.comp.lib.boost.devel/9616
>>
>> Are they inapplicable in this case?
>
> Completely relying on MOJO or similar techniques would require, that I'm
> able/allowed to _modify_ the base iterator code, which isn't always
> true.

I'm not talking about relying on MOJO, I'm talking about andrei's
finding that on compilers that elide copies, passing objects by
reference if they're just going to be copied anyway is almost always a
mistake.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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