Skip to content

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

Merged
mjcarroll merged 1 commit intogazebosim:mainfrom
jwnimmer-tri:tidy-rule-of-zero-and-virtual
Nov 30, 2021
Merged

Tidy up copy, copy-assign, and destructors#293
mjcarroll merged 1 commit intogazebosim:mainfrom
jwnimmer-tri:tidy-rule-of-zero-and-virtual

Conversation

@jwnimmer-tri
Copy link
Copy Markdown
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 <jeremy.nimmer@tri.global>
@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.

6 participants