Pull Request №705 RosettaCommons/rosetta/main ← lyskov-ai/rosetta/refactor/key-containers-rule-of-zero-redo
Merge: b2a0ff32f3ee01822f6f18b9d21ea27357a5f6bc←f7927e886605c9074a69feb917a084fac42262d8
Apply Rule of Zero to utility/keys container family (corrected)
----------------
Merge commit message:
Apply Rule of Zero to utility/keys container family
Applies Rule of Zero to five sibling key-container templates in
`source/src/utility/keys/`:
- `ClassKeyMap`
- `ClassKeyVector`
- `KeyVector`
- `SmallKeyMap`
- `SmallKeyVector`
Each held only standard-container value-type members (a `Vector`,
plus an `IndexMap` and a scalar `Index u_` in the `Small*` variants).
Their user-declared destructors (empty body or `= default`), copy
constructors, and copy-assignment operators were byte-for-byte
equivalent to the implicit defaults the compiler would synthesize,
so they were redundant.
Removing them lets the implicitly defaulted special-member-functions
take over and, as a side effect, restores the implicit move
constructor and move assignment that were previously suppressed by
the user-declared copy operations.
Explicit `= default` default constructors are kept on all five
classes. `SmallKeyMap` / `SmallKeyVector` need a user-defined default
constructor to value-initialize the scalar `Index u_`, which an
implicit default would leave indeterminate. `ClassKeyMap` /
`ClassKeyVector` / `KeyVector` need an explicit `= default` because
each has a user-declared (non-default) constructor (iterator-range
or size/value), and a class with any user-declared constructor does
not get an implicitly synthesized default. The previous attempt at
this refactor (#691, reverted by #703) dropped these `= default`
defaults on the assumption that they would be synthesized
implicitly, which broke `ClassKeyMap m;` in test/utility/keys/
ClassKeyMap.cxxtest.hh. Keeping the explicit defaults preserves the
original API while still letting copy / move / destructor be
implicit. Supersedes #704.