Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't mix "default operations" and "special functions" in C.xx sections #2224

Open
miemoe opened this issue Oct 4, 2024 · 0 comments
Open

Comments

@miemoe
Copy link

miemoe commented Oct 4, 2024

In the C.xx sections we can find the term: "default operations" a lot.
I don't think the terms are used correctly in every place.

In the same sections we can find 2 times: "special functions".
I think the ISO standard uses the term: "special member functions".

In my understanding the "default operations" are "special member functions" that the compiler can generate for you by default.
If you define the "special member functions" then the compiler will only generate some of "default operations".

E.g. the section

C.ctor: Constructors, assignments, and destructors

These functions control the lifecycle of objects: creation, copy, move, and destruction.
Define constructors to guarantee and simplify initialization of classes.

These are default operations:

a default constructor: X()
a copy constructor: X(const X&)
a copy assignment: operator=(const X&)
a move constructor: X(X&&)
a move assignment: operator=(X&&)
a destructor: ~X()

By default, the compiler defines each of these operations if it is used, but the default can be suppressed.

should be:

C.ctor: Constructors, assignments, and destructors

These special member functions control the lifecycle of objects: creation, copy, move, and destruction.
Define constructors to guarantee and simplify initialization of classes.

These are special member functions:

a default constructor: X()
a copy constructor: X(const X&)
a copy assignment: operator=(const X&)
a move constructor: X(X&&)
a move assignment: operator=(X&&)
a destructor: ~X()

By default, the compiler defines default operations for each of these functions if it is used, but the default can be suppressed.

The lines following this intro C.20, C.21, ... should be checked, for correctness of usage of "default operations."

e.g. C.20 should be
C.20: If you can avoid defining special member functions, do
as defining "default operations" in contractionary it itself: How can a user define a default ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant