- Ban forward declaration of entities not owned by the project.
- Recommend `absl::down_cast` for downcasting instead of `static_cast`.
- Expanded and reworked guidance on `auto` for variables and function
parameters: in particular, encourage structured bindings for map-like
containers.
- Remove Boost section and add a section for third-party libraries with
general guidance.
- Other minor updates and improvements to wording, et cetera.
- Clarify that TODO styles are listed in order of preference
- No space between type and `*` or `&`
- Minor wording updates for structs and move semantics
- Allow naming exceptions for Rust interop
- Allow coroutine use via libraries approved by project leads
- Disallow using a space before `*` and `&` for pointer and reference
types
- Simplify guidance for using vertical whitespace
- Other minor formatting / typography / wording fixes, e.g. adding
goodcode/badcode annotations to examples
- Expand guidance around usage of functions (and variables) with inline
definitions.
- Change guidance around internal namespaces to reduce the likelihood of
collisions.
- Expand naming guidance, with specific additional rules around:
- nested namespaces not reusing well-known top-level names
- template parameters
- name aliases
- Clarify that constant-style naming also applies to static class
constants.
- Other miscellaneous formatting and documentation improvements, e.g.
additional Abseil TotW links.
This is the GH avatar and is slightly different from the icon used on
other Google properties. This makes it easier to distinguish in a big
tab strip.
Fixes: #489
We have not pushed updates to the public cpplint code from our internal
version in years. No one seems interested in picking it up either.
Since an open source community has formed & forked & updated it, let's
delete our ancient version and just send people to that project now.
- Explicitly ban `long double`
- Use absl formatting libraries or `std::ostream` over printf-style
functions.
- Portability: use serialization libraries instead of copying the
in-memory representation.
- Update guidance to use `uintptr_t` (previously `intptr_t`) when
working with pointers as integers.
- Ban C++20 modules.
- Ban coroutines (though this is expected to be temporary).
- Minor wording updates.
- Give more explicit guidance about when angle bracket includes should
be used.
- Expand the guidance for disallowing const reference parameters that
outlive the call to *all* references, const or mutable; instead, these
parameters should be pointers.
- Add a brief section about how concepts should be named
There are also additional minor formatting changes or updating
recommendations to prefer std over absl.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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
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.
- 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).
- 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.
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