isocpp / isocpp/CppCoreGuidelines
Clarification on the scope of rule C.83
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 45.3k
- Forks
- 5.6k
- PR merge metrics
- No merged PRs in 30d
Description
The company I work for employs a third party static code quality checker. This tool has recently adopted a number of additional checks. One of them is rule C.83. The tool very literally implements the mentioned enforcement "A class without virtual functions should have a swap member function declared."
The consequence of this is that any Plain Old Datatype and non-polymorphic class is flagged if it misses the swap method.
The solution advised is to add
class C
{
...
void swap(C &other) noexcept { std::swap(*this, other); }
...
};
in such cases.
I wonder if this was the intention of the rule and if perhaps some context is missing as to when to apply this rule.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the C.83 section in CppCoreGuidelines.md and compare its stated enforcement with the examples and wording referenced in the issue. Clarify whether the rule applies to all non-polymorphic classes or needs additional context; done means the guideline's scope is explicit enough to resolve the static-checker interpretation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100