-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: mention smart pointers in Cpp style guide #17055
Conversation
CPP_STYLE_GUIDE.md
Outdated
@@ -1,5 +1,23 @@ | |||
# C++ Style Guide | |||
|
|||
## Table of Contents | |||
|
|||
* [Left-leaning (C++ style) asterisks for pointer declarations](#left-leaning-c-style-asterisks-for-pointer-declarations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really need to be done in this PR, but we should probably put these rules into different categories so they would be easier to look up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I think #17052 is actually adding ToC there, maybe this PR should not include that change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's kind of why I added a Table of Contents, so folks get an idea of all the rules even if they don't scroll all the way to the bottom. If anybody has a good idea how to order them, I'm all for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, we have a linter that enforces all the rules 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fhinkel Yes, but an easy-to-extend and easy-to-use C++ linter is not easy to come by as their JavaScript counterparts.. I've been looking into clang-tidy while working on #16122, but that requires a compilation database, we do have ninja support that can emit those, still it probably raise the barrier of entry too high for new contributors..
Add rule for smart pointers, i.e., std::unique_ptr and std::shared_ptr, to the Cpp style guide. Mostly copied from the Google style guide.
e5cf1c6
to
adadaf8
Compare
Landed in 0e1abb1. |
Add rule for smart pointers, i.e., std::unique_ptr and std::shared_ptr, to the Cpp style guide. Mostly copied from the Google style guide. PR-URL: #17055 Ref: #16970 Ref: #16974 Ref: #17000 Ref: #17012 Ref: #17020 Ref: #17030 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Add rule for smart pointers, i.e., std::unique_ptr and std::shared_ptr, to the Cpp style guide. Mostly copied from the Google style guide. PR-URL: #17055 Ref: #16970 Ref: #16974 Ref: #17000 Ref: #17012 Ref: #17020 Ref: #17030 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Add rule for smart pointers, i.e., std::unique_ptr and std::shared_ptr, to the Cpp style guide. Mostly copied from the Google style guide. PR-URL: #17055 Ref: #16970 Ref: #16974 Ref: #17000 Ref: #17012 Ref: #17020 Ref: #17030 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Add rule for smart pointers, i.e., std::unique_ptr and std::shared_ptr, to the Cpp style guide. Mostly copied from the Google style guide. PR-URL: #17055 Ref: #16970 Ref: #16974 Ref: #17000 Ref: #17012 Ref: #17020 Ref: #17030 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Add rule for smart pointers, i.e., std::unique_ptr and std::shared_ptr,
to the Cpp style guide. Mostly copied from the Google style guide.
I started changing raw pointers to smart pointers in several C++ files.
std::unique_ptr has almost no overhead compared to raw pointers
and makes the code less error-prone. Are there any objections to
adding the usage of smart pointers as a rule to our style guide?
Ref: #16970
Ref: #16974
Ref: #17000
Ref: #17012
Ref: #17020
Ref: #17030
Checklist
Affected core subsystem(s)
doc
This needs to be rebased after #17052 lands (should only be the second commit).