microsoft / microsoft/terminal
Guidance around const by-value function parameters
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 105k
- Forks
- 9.6k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 29
Description
Clarification is needed around const by-value function parameters. I noticed in a lot of the code, by-value function parameters are marked const. Some code doesn't follow this rule though.
Examples in interactivity/win32/Clipboard.cpp
void Clipboard::Copy(bool fAlsoCopyHtml)
void Clipboard::StoreSelectionToClipboard(bool const fAlsoCopyHtml)
In the CppCoreGuidelines
Con.1: By default, make objects immutable
They have an exception
Exception
Function arguments are rarely mutated, but also rarely declared const. To avoid confusion and lots of false positives, don't enforce this rule for function arguments.
void g(const int i); // pedantic
What is the team's stance on this?
This issue is just a reminder when we create the styleguide in #890 to include something around the team's 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
Review the const and non-const by-value parameter examples in interactivity/win32/Clipboard.cpp and compare them with CppCoreGuidelines Con.1. Determine the team's stance, then document that rule in the style guide planned in issue #890. Done means the style guide clearly states whether const by-value parameters should be used.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100