C++ styleguide updated: mutable references and more

126 views
Skip to first unread message

Peter Kasting

unread,
Jun 2, 2020, 6:19:58 PM6/2/20
to Chromium-dev, blink-dev
TLDR: The public Google C++ styleguide has been updated with a variety of changes, most significantly allowing mutable reference arguments.

Recently the public Google styleguide was updated with a number of significant changes.  Here are the biggest ones, and how they affect Chromium:

No effect:
Affects Chromium but not Blink:
  • For output and in/out parameters that cannot be null, Google now prefers mutable references, instead of pointers.  This is roughly equivalent to existing Blink style; the Blink styleguide has therefore been updated to remove mention of this, since it is no longer a divergence from Chromium style.  Note that return values are still preferred over output parameters, including when a function needs to return multiple values.
Affects Chromium and Blink:
Finally, this is a good time to remind people that DISALLOW_COPY_AND_ASSIGN is deprecated in new code; explicitly delete the copy/assign operators between your constructors and destructor.

As always, if you have questions or feedback about C++ style, send mail to c...@chromium.org and/or hop on the #cxx channel on the Chromium Slack.

PK

Peter Kasting

unread,
Jun 2, 2020, 6:54:19 PM6/2/20
to Chromium-dev, blink-dev
On Tue, Jun 2, 2020 at 3:19 PM Peter Kasting <pkas...@google.com> wrote:
That last link should have gone to https://chromium-cpp.appspot.com/ .

PK 

Michael Lippautz

unread,
Jun 15, 2020, 6:30:43 AM6/15/20
to Peter Kasting, Chromium-dev, blink-dev
On Wed, Jun 3, 2020 at 12:19 AM 'Peter Kasting' via blink-dev <blin...@chromium.org> wrote:
Affects Chromium but not Blink:
  • For output and in/out parameters that cannot be null, Google now prefers mutable references, instead of pointers.  This is roughly equivalent to existing Blink style; the Blink styleguide has therefore been updated to remove mention of this, since it is no longer a divergence from Chromium style.  Note that return values are still preferred over output parameters, including when a function needs to return multiple values.

Will this be applied globally (cpplint.py) or are we supposed to adjust dependent projects manually by adding "runtime/references" to a linter whitelist?
Reply all
Reply to author
Forward
0 new messages