Created on1998-10-24.00:00:00 last changed277 months ago
Proposed Resolution (10/99):
[Note: a small portion of this wording is superseded by theresolution ofissue 185.]
The paragraph in question should be rewritten as follows.In addition,references to this section should be added to the index under "temporary,elimination of," "elimination of temporary," and "copy, constructor elision."
in a return statement in a function with a class return type, where theexpression is the name of a non-volatile automatic object with the samecv-unqualified type as the function return type, the copy operation canbe omitted by constructing the automatic object directly into the function'sreturn value
class Thing { public: Thing(); ~Thing(); Thing(const Thing&); }; Thing f() { Thing t; return t; } Thing t2 = f();Here the criteria for elision can be combined to eliminate two calls tothe copy constructor of classThing: the copying of the localautomatic objectt into the temporary object for the return valueof functionf() and the copying of that temporary object intoobjectt2. Effectively, the construction of the local objecttcan be viewed as directly initializing the global objectt2, andthat object's destruction will occur at program exit.—end example]Issue 1
11.4.5.3 [class.copy.ctor](From J16/99-0005 = WG21 N1182, "Proposed Resolutions for CoreLanguage Issues 6, 14, 20, 40, and 89")
There are three related sub-issues in this issue, all dealing with theelision of copy constructors as described in11.4.5.3 [class.copy.ctor]paragraph 15:
After discussion in Santa Cruz, the core group decided that sub-issue#1 required no change; the necessity of an accessible and unambiguous copyconstructor is made clear in6.8.7 [class.temporary]paragraph 1 and need not be repeated in this text. The remaining two sub-issuesappear to be valid criticisms and should be addressed.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2003-04-25 00:00:00 | admin | set | status: dr -> tc1 |
| 2000-02-23 00:00:00 | admin | set | status: ready -> dr |
| 1999-09-14 00:00:00 | admin | set | messages: +msg85 |
| 1999-09-14 00:00:00 | admin | set | status: open -> ready |
| 1998-10-24 00:00:00 | admin | create | |