Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can anyone explain this paragraph of the current C++0x standard draft?

Can anyone explain this statement from ISO N3242 §3.2, 2nd point

A non-placement allocation or deallocation function for a class is odr-used by the definition of a constructor of that class. A non-placement deallocation function for a class is odr-usedby the definition of the destructor of that class, or by being selected by the lookup at the point of definitionof a virtual destructor (12.4).26 A copy-assignment function for a class is odr-used by an implicitly-defined copy-assignment function for another class as specified in 12.8. A move-assignment function for a class is odr-used by an implicitly-defined move-assignment function for another class as specified in 12.8.

ISO Standard 2003 says:

A copy-assignment function for a class is used by an implicitly-defined copy-assignment function for another class as specified in 12.8.

What is the actual difference in these statements?

Any one explain the above added point in terms of example/program...?

I know move constructor / move assigment function -->new feature added .

Can any one explain this with the help of an example/program?

please.............

please.......... answer

like image 933
1User Avatar asked Apr 11 '11 10:04

1User


1 Answers

The rationale for this addition, with examples can be found here. In short, it is a clarification of exactly when an allocation/deallocation function for a class needs to be defined.

The (C++03) One Definition Rule requires that every variable or function that is used in the program, for a very specific definition of "use", must have exactly one definition. Therefore, a description of when a (de)allocation function is considered "used", also mandates when a definition is required.

To avoid confusion between the general meaning of the word "use", and the meaning of "use" as defined in ODR, the word "use" has been replaced with "odr-use" whenever the second meaning is intended.

like image 78
decltype Avatar answered Oct 11 '22 10:10

decltype