Skip to content

Apply Rule of Zero to empty destructors across core/#706

Open
lyskov-ai wants to merge 1 commit into
RosettaCommons:mainfrom
lyskov-ai:refactor/core-empty-dtors-rule-of-zero
Open

Apply Rule of Zero to empty destructors across core/#706
lyskov-ai wants to merge 1 commit into
RosettaCommons:mainfrom
lyskov-ai:refactor/core-empty-dtors-rule-of-zero

Conversation

@lyskov-ai
Copy link
Copy Markdown
Contributor

Summary

Move trivially empty (~X() {}) or = default;-bodied destructors from .cc files to header declarations using = default, and remove the now-redundant .cc implementations. Where a destructor was declared ~X() {} inline in a header, switch it to ~X() = default; for the same reason.

This unlocks the implicit move-special-members the user-declared destructors were suppressing and removes pure-noise boilerplate.

Affected sibling groups

  • core/conformation/membrane/{AqueousPoreParameters, ImplicitLipidInfo, MembraneGeometry, MembraneInfo} and membrane_geometry/{Bicelle, DoubleVesicle, Slab, Vesicle} — 8 classes
  • core/conformation/parametric/{Boolean, Real, RealVector, Size, SizeVector}ValuedParameter — 5 classes
  • core/io/silent/SilentFileData::{iterator, const_iterator} — inline empty dtors removed
  • core/pack/interaction_graph/RotamerDots.{hh,cc}DotSphere, RotamerDots, RotamerDotsCache, InvRotamerDots
  • core/scoring/etable/EtableEnergy.{hh,cc}EtableEvaluator, AnalyticEtableEvaluator, TableLookupEvaluator
  • core/scoring/hbonds/graph/HBondInfo.hhLKHBondInfo, HBondInfo (also removed an unused user-defined empty copy ctor on LKHBondInfo)
  • core/scoring/nmr/NMRDummySpinlabelVoxelGrid.{hh,cc}VoxelGridPoint, NMRDummySpinlabelAtom, VoxelGridPoint_AA, NMRDummySpinlabelVoxelGrid
  • core/scoring/sc/MolecularSurfaceCalculator::Atom
  • core/energy_methods/SAXSEnergy

No behavior changes — pure code-style refactor.

Move trivially empty or `= default;`-bodied destructors from .cc files to
header declarations using `= default`, then remove the now-redundant .cc
implementations. Where a destructor was declared `~X() {}` inline in a
header, switch it to `~X() = default;` for the same reason.

Affected sibling groups:
- core/conformation/membrane/* and membrane_geometry/* (8 classes)
- core/conformation/parametric/*ValuedParameter (5 classes)
- core/io/silent/SilentFileData iterator and const_iterator
- core/pack/interaction_graph/RotamerDots family (4 classes)
- core/scoring/etable/EtableEvaluator hierarchy (3 classes)
- core/scoring/hbonds/graph/HBondInfo (2 classes)
- core/scoring/nmr/NMRDummySpinlabelVoxelGrid family (4 classes)
- core/scoring/sc/MolecularSurfaceCalculator::Atom
- core/energy_methods/SAXSEnergy
Copy link
Copy Markdown
Member

@roccomoretti roccomoretti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine as far as it goes, but putting ~Class() override = default is unnecessary, as the only benefit of declaring a default destructor is being able to label it virtual. (Which it already has to be with the override.)

IIRC, the "unlocks the implicit move-special-members" isn't quite correct -- explicitly defaulting the destructor still counts as "user defined" for the purposes of suppressing the implicit move functions. (Which is why just leaving it off is typically preferred.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants