Apply Rule of Zero to old-style uncopyable classes in core/ and protocols/#697
Open
lyskov-ai wants to merge 2 commits into
Open
Apply Rule of Zero to old-style uncopyable classes in core/ and protocols/#697lyskov-ai wants to merge 2 commits into
lyskov-ai wants to merge 2 commits into
Conversation
…cols/ Modernize 31 files that used the pre-C++11 idiom of declaring (but not defining) private copy constructor and assignment operator to forbid copies. The link-error-as-enforcement trick predates `= delete` and is fragile (silent same-translation-unit ICE breakage, confusing diagnostics). Two flavours of fix: 1. Stand-alone non-copyable classes (InteractionGraphBase node/edge/graph family, FlexbbInteractionGraph, JobDigraph, AtomTreeCollection's ResidueAtomTreeCollection, Matcher, MonteCarlo's operator=): replace the unimplemented private declarations with public `= delete` copies. Where the old assignment took a non-const reference or returned `T const &` that was a holdover from the C++03 idiom; the modernized signatures take `T const &` and return `T &`. 2. Singleton-derived factories (utility::SingletonBase children): drop the redundant unimplemented copy/assignment declarations entirely. The base class already `= delete`s its own copy/assignment, which transitively makes the derived class's implicit copies deleted, so the extra lines were noise. No behaviour change: copies/assignments that were link errors before are now compile errors, which is the intended improvement in diagnostic quality. Debug build passes clean.
Clang's -Wunused-private-field is suppressed while a class has any declared (even unimplemented) private copy constructor / assignment, because the compiler can't prove those bodies don't touch the field. Replacing those declarations with = delete in PR RosettaCommons#697 let clang fully analyze member usage, surfacing five orphaned scalar fields whose only references live inside large /* ... */ blocks of disabled I/O code: - DoubleLazyNode::procrastinated_ - LazyNode::procrastinated_ - LazyInteractionGraph::num_aa_types_ - PDInteractionGraph::num_nodes_in_file_ - PDInteractionGraph::num_file_aa_types_ Drop the fields and the matching constructor initializers. The commented I/O functions that reference them are left alone (already dead).
lyskov
approved these changes
May 15, 2026
roccomoretti
approved these changes
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Modernize 31 headers across
core/andprotocols/that used the pre-C++11 idiom of declaring (but not defining) private copy constructor and assignment operator to forbid copies. The link-error-as-enforcement trick is fragile (silent breakage if anyone defines them in the same translation unit, confusing diagnostics on misuse, and falsely implies the class has a copy constructor).Two flavours of fix applied:
Stand-alone non-copyable classes — InteractionGraphBase node/edge/graph family (9 files, 23 classes total), FlexbbInteractionGraph (2 classes), JobDigraph (2 classes), AtomTreeCollection's ResidueAtomTreeCollection, Matcher, and MonteCarlo's
operator=: replace the private unimplemented declarations with public= delete. Where the old assignment took a non-const reference or returnedT const &(a C++03 idiom holdover), the modernized signatures takeT const &and returnT &.Singleton-derived factories (
utility::SingletonBasechildren) —RotamerLibrarySpecificationFactory,SingleResidueRotamerLibraryFactory,RotamerLibrary,CenrotLibrary, plusDockingHighResFactory,EvaluatorFactory,JobInputterFactory,JobOutputterFactory,LoopMoverFactory,LoopRefineInnerCycleFactory,LoopsDefinerFactory,GridFactory,PoseSelectorFactory,RotamerRecoveryFactory,AssemblyRequirementFactory,AssemblyScorerFactory: simply drop the redundant unimplemented copy/assignment declarations.SingletonBasealready= deletes its own copy/assignment, which transitively deletes the derived class's implicit versions, so the extra lines were noise.No behaviour change: copy/assignment attempts that were link errors before are now compile errors, which is the intended diagnostic-quality improvement. Debug build passes clean.