From: David Abrahams (dave_at_[hidden])
Date: 2005-05-02 19:40:17
"Gennadiy Rozental" <gennadiy.rozental_at_[hidden]> writes:
>>> And dangerous. Cause allows developer to "forget" about an extra
>> 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
Are you sure that copy can't be elided?
> 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.
Not danger; inefficiency.
> Ok. I agree to keep this functionality. But there
> should be a bug disclaimer about this overhead.
Not bug... I don't know what.
-- 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