Commit Graph

31 Commits (4153bf1f8c172fcb58593193238b0a928e58e61e)

Author SHA1 Message Date
Daniel Cheng 901474aa08 Update C++ style guide for C++20.
- Encourage single line nested namespace declarations.
- Reference and allow `constinit` in the relevant sections
- Update operator overloading guidance for comparison operators: prefer
  only to overload `==` and optionally `<=>` when there is an obvious
  ordering, and allow the compiler to derive the other comparison
  operators.
- Discourage prefixing `uint32_t`, et cetera with `std::`.
- Document when and how to use concepts:
  - Use `requires` expressions rather than the alternatives, e.g. a
    template parameter.
  - Do not reimplement existing concepts/traits.
  - Do not expose concepts across API boundaries.
  - Do not use concepts unnecessarily.
  - Do not implement concepts that are not compile-time checkable.
2023-10-12 09:48:56 -07:00
Daniel Cheng d8cee7085b Update C++ style guide.
- Update caveats for `thread_local` usage, particularly around the risk
  of destruction order issues.
- Provide explicit guidance for situations where `bit_cast` may be a
  better fit than `reinterpret_cast`.
- Emphasize that kConstant-style naming can still be used for `const`
  automatic variables that are initialized at runtime, but only if the
  resulting variable has the same value with each evaluation (i.e. it
  does not depend on runtime inputs).
- Clarify what sorts of details belong in file-level comments vs
  comments for individual abstractions.
- Update TODO examples to reflect the preferred styling, from most
  preferred to least preferred.
2023-08-22 14:03:40 -07:00
Daniel Cheng f1dbcc3382 Update C++ style guide.
- Encourage use of the `internal` namespace to document parts of an API
  that are not public.
- Create a separate section for `switch` statements.
- Require a project-specific prefix for macros.
- Reorganize guidance for formatting conditional statements.
- Other miscellaneous wording and formatting fixes.
2023-03-22 14:39:28 -07:00
Daniel Cheng 78c5bdd851 Update C++ style guide.
- Include friend types in class declaration order guidance.
- Include previously omitted text (due to mismatched tags) about
  preferring int16_t over short, et cetera.
- Function declarations:
  - Updated guidance for what comments should cover.
  - Add a C++ attribute example.
2022-07-05 22:28:56 +00:00
Daniel Cheng 93c7bd88c6 Update C++ style guide.
- Reword guidance for definitions of inline functions and templates.
- Capitalize the first letter of various comments.
- Update command-line flag reference to use absl flags.
- Improve braced-initialization example for 64-bit constants.
- Delete C++03 guidance for NULL.
- Clarify wording around wrapping of string literals.
- Use C++17 [[fallthrough]] instead of ABSL_FALLTHROUGH.
2022-05-03 23:57:01 +00:00
Daniel Cheng 840e5839f6 Update the C++ style guide.
- Recommend the use of absl::implicit_cast for safe upcasting.
- Remove std::hash guidance
- Remove end-of-line comment guidance
- Remove "consistency to local style" guidance
- Miscellaneous wording updates
2021-10-20 09:17:56 -07:00
Jesse Ruderman b1956b20a2
cppguide: remove space before comma 2021-07-20 08:53:06 -07:00
Daniel Cheng 4e25657924 Update C++ style guide.
Mostly minor wording updates (e.g. preferring int64_t to int64). The
most significant change is clarifying the section on consistency to
clarify that consistency, in and of itself, should not be used as the
sole argument for blocking adoption of style changes.
2021-03-26 16:54:25 -07:00
Daniel Cheng a4413633ec Update C++ style guide.
Minor formatting and wording fixes.
2021-01-29 11:04:19 -08:00
Daniel Cheng ed3dd33df3 Update Google C++ styleguide
- Guidance for return values (prefer return by value, return by
  reference, then return by pointer in that order)
- Mandate curly braces around the body of a control statement,
  providing one exception for historical reasons (`if` with no `else`,
  and `if` + body fits completely in a single line or the `if` fits in
  one line and the body fits in another separate line).
2020-11-10 22:26:05 -08:00
Daniel Cheng 3919c347aa Update C++ styleguide
- add section for inclusive language.
- move include-what-you-use to a new section.
- clarify usage of absl::optional for by-value vs by-reference params.
- document usage of `` as a code-indexing hint
- note that enclosing identifiers in `` can help code indexers.
2020-09-25 00:29:52 -07:00
Daniel Cheng d8467c6dcf [C++ styleguide] Restore table of contents
This was mistakenly dropped when updating the styleguide from the
internal C++ styleguide.
2020-05-27 01:07:22 +00:00
Daniel Cheng 7a7a2f510e Update C++ styleguide
Major changes:
- discourage const references when the input parameter must outlive the
  call
- drop ban on mutable references
- allow rvalue-qualified methods in certain situations
- allow C-style cast when casting to void
- disallow postfix increment/decrement operators unless postfix
  semantics are required
- allow designated initializers in C++20-compliant form
- disallow macro-style naming for enumerator constant for new code
- disallow spaces inside parentheses for conditionals

The change itself is largely automated, with a few manual adjustments:
- manually restore the TOC placeholder
- removed trailing whitespace
2020-05-20 17:14:04 +00:00
Victor Costan 967e157a00 Update C++ style guide for C++17. 2019-09-05 05:09:38 -07:00
Victor Costan f0314ea7e0 Update C++ style guide. 2019-09-01 21:07:27 -07:00
Tom Manshreck 63107a12eb
Update cppguide.html 2018-08-14 16:12:59 -04:00
Victor Costan b89a775fa7 Update C++ style guide 2018-08-02 15:54:34 -07:00
Victor Costan 4b9c0c0389 Minor updates to C++ style guide. 2018-02-21 05:44:55 -08:00
Victor Costan 6dfd9d9de9 Update C++ styleguide to revision 3.277. 2018-02-07 12:42:22 -08:00
Ted Osborne 505ba68c74 Revert "Project import generated by Copybara."
This reverts commit 54cca78d64.
2018-01-30 12:36:50 -05:00
Google Python team 54cca78d64 Project import generated by Copybara.
PiperOrigin-RevId: 179577576
2018-01-30 12:10:03 -05:00
roooooooot a33bdd6e3a Fix a typo
requre -> require
2016-12-31 13:10:07 +08:00
Stephen Hicks db0a26320f Update Java and C++ style guides with various changes since the last update. 2016-11-17 18:02:44 -08:00
Titus Winters f15e633de5 Update to current.
This notably includes changes for namespace naming and use of auto, as
well as clarification on when comments are necessary and attribute
placement.
2016-07-06 12:12:21 -04:00
Ackermann Yuriy 7969290bac Replaced HTTP where HTTPS been awailable. 2016-04-01 21:41:34 +13:00
Alan Yee 04b42100ea Grammar fix
Replaced "less" with "fewer"
2016-03-01 13:49:01 -08:00
Titus Winters 0124f309e4 Update to current.
Most significant updates:
* Casting (for arithmetic types, maybe use {}s)
* Namespaces
* Aliases
2016-01-06 16:09:22 -05:00
Mark Mentovai 14ab228ab6 Restore missing newline 2016-01-04 10:49:37 -05:00
Roman Franchuk 7e0bcd7e29 Fix links in C++ guide to point to GitHub
The links were pointing to googlecode.com. Two of them resulted in "404
Not Found", one resulted in the message "the project is moved".
2015-11-01 12:52:05 +02:00
Geoff Romer 3591b2e540 Update C++ Style Guide to 4.177. 2015-09-11 15:09:00 -07:00
mark@chromium.org 3ed10fb207 Update C++ style guide to 4.45.
Much of the guide has been refactored, rewritten, and revised.
2014-09-08 17:01:51 +00:00