|
Prev: template
Next: Operator!= injection (from std::rel_ops)
From: Dizzy on 15 Jan 2008 20:14 Hi Alan McKenney wrote: > After reading yet another discussion of > the Return Value Optimization, and how > it has received Explicit Dispensation from > the Holy Standard, I can't help wondering: > > why not allow copy constructors to be optimized > away _whenever_ a copy isn't really necessary? > > As a preliminary definition of "isn't really necessary," > I'll propose "when you start with one object and end > up with one." (I'm sure that this needs some tightening > up.) That sounds exactly like what move semantics solves (eliminating copies of temporary values, ie rvalues). On that topic you might want to check out: * http://www.ddj.com/cpp/184403855 an article discussing this and possible solutions with current C++ * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1377.htm the rvalue references proposal for C++0x that will make implementing move semantics much easier (and when the standard containers and such will get those move constructors your code which copied temporaries will automatically use move semantics and avoid the copy with just a recompilation) -- Dizzy [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
|
Pages: 1 Prev: template Next: Operator!= injection (from std::rel_ops) |