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

Definition in rule of five within non-normative code snip #489

Open
mkinsner opened this issue Nov 2, 2023 · 2 comments · May be fixed by #737
Open

Definition in rule of five within non-normative code snip #489

mkinsner opened this issue Nov 2, 2023 · 2 comments · May be fixed by #737
Labels
bug Something isn't working

Comments

@mkinsner
Copy link

mkinsner commented Nov 2, 2023

The spec describes the rule of five as:

// If any of the following five special member functions are not
// public, inline or defaulted, then all five of them should be
// explicitly declared (see rule of five).

To me this is a strange way to word it (not as easy to reason about as many other definitions), and although I'm probably missing something, I don't see how inline fits in. The wording also seems incorrectly inverted in my current reading.

@nliber can you please weigh in here? Is the current wording correct, and any opposition to rewording this to be more like the following?

If any of the following five special member functions are defined or declared as either defaulted or deleted, then all five of them should be explicitly declared (see rule of five).

@nliber
Copy link
Collaborator

nliber commented Nov 7, 2023

I am planning on saying something, but didn't get to it before leaving for the WG21 Meeting. :-(. I'm waiting for a brief moment to write something coherent, but so far the WG21 meeting is all-consuming...

@nliber
Copy link
Collaborator

nliber commented Dec 12, 2023

As stated in the spec, the rule is not correct. If one declares any of the five, then we get the complicated rules of which special member functions are implicitly generated and which ones are not (which is what the Rule of Five is trying to avoid).

@mkinsner I would shorten your proposed wording to:

If any of the following five special member functions are declared, then all five of them should be explicitly declared (see rule of five).

@Pennycook Pennycook added the bug Something isn't working label Feb 24, 2025
@Pennycook Pennycook linked a pull request Feb 24, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants