Boost logo

Boost :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2005-05-02 16:33:20

>> And dangerous. Cause allows developer to "forget" about an extra
>> copy.
> I'm not sure where you think the "extra" copy is. The copy is already
> implicit in the RHS expression, isn't it?

No. In this case we could control the copy.

collection foo();

returns temporary. FOREACH make copy of this temporary into another
temporary. This is an extra copy. Which we could easily control/eliminate

collection const& c = foo();


> In general C++ will make lots of copies you can't control. Extra
> copies are hardly "dangerous" (except maybe with auto_ptr). They may
> be inefficient, but then I don't believe in trying to prevent people
> from writing inefficient code, especially when that's more convenient.
> Very little of the code end users write actually needs to be fast.

That's true. But danger in this case caused by the fact that FOREACH make
an extra copy silently. Ok. I agree to keep this functionality. But there
should be a bug disclaimer about this overhead.


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