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

Tidy up copy, copy-assign, and destructors #293

Merged

Conversation

jwnimmer-tri
Copy link
Contributor

@jwnimmer-tri jwnimmer-tri commented Nov 24, 2021

🦟 Bug fix

Somewhat related to #269 -- a class with a virtual destructor cannot be constexpr.

Summary

Tidy up copy, copy-assign, and destructors

Remove virtual from destructors of copyable classes. A class that is copyable or copy-assignable should never be virtual, because any subclass will be subject to the slicing problem.

Use = default anytime we just want the default implementation. Writing out the list of member fields by hand is error-prone.

Checklist

  • Signed all commits for DCO
  • Added tests (N/A)
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge

Remove virtual from destructors of copyable classes.  A class that is
copyable or copy-assignable should never be virtual, because any subclass
will be subject to the slicing problem.

Use '= default' anytime we just want the default implementation.  Writing
out the list of member fields by hand is error-prone.

Signed-off-by: Jeremy Nimmer <[email protected]>
@jwnimmer-tri jwnimmer-tri marked this pull request as ready for review November 24, 2021 18:42
@mjcarroll mjcarroll merged commit 1366e82 into gazebosim:main Nov 30, 2021
@jwnimmer-tri jwnimmer-tri deleted the tidy-rule-of-zero-and-virtual branch November 30, 2021 20:05
@chapulina chapulina mentioned this pull request Jul 6, 2022
9 tasks
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

Successfully merging this pull request may close these issues.

3 participants