镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

c++: Adopt the CppCoreGuidelines #22862

Closed

Description

@refack

Now that we build with C++14 enabled:

I believe it's time we start adopting the CppCoreGuidelines
http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines

Activity

  1. added
    c++Issues and PRs that require attention from people who are familiar with C++.
    discussIssues opened for discussion and feedback.
    on Sep 14, 2018
  2. richardlau commented on Sep 14, 2018

    @richardlau
    Member

    We still use -std=gnu++0x on v8.x -- Are the guidelines compatible (bearing in mind backports)?

  3. addaleax commented on Sep 14, 2018

    @addaleax
    Member

    This seems to be a very broad guide on writing good C++, so what exactly does “adopt” mean here? Also, some of these are incompatible with our own existing guidelines (e.g. use of non-const references).

  4. refack commented on Sep 14, 2018

    @refack
    ContributorAuthor

    From a community POV, having an explicit and concise "guidebook" to C++ can be a huge benefit for newcomers (and current contributors who want to expand to C++). Especially since C++ is so expressive and flexible, even after learning the language knowing what is the right way to do something is very hard.

    I don't believe we need/can/should refactor the existing code. IMHO it's similar to when we discussed ES-next, i.e. when writing new code or fixing existing code, CCG guidelines should take precedence.


    We still use -std=gnu++0x on v8.x -- Are the guidelines compatible (bearing in mind backports)?

    @richardlau, most of the clauses in the CCG are stylistic, and do not necessarily require new language features. They do at times recommend new features, but explain why, and how to handle legacy situations.

    We need as always to balance comfort and progress with code backportability.
    v8 will enter maintenance in ~6 months, so it's not that far away. Also in C++ code we have the compiler (not just git) to verify that backported changes are consistent.


    This seems to be a very broad guide on writing good C++, so what exactly does “adopt” mean here?

    @addaleax IMHO “adopt” means accepting those guidelines as the default. Reviewing PRs with the CCG in mind, and requesting explanations when authors overrules them.
    There are also tools (MSVS, and clang-tidy) that help check and flag situations that are covered by the CCG. We could incrementally add those.

    Also, some of these are incompatible with our own existing guidelines (e.g. use of non-const references).

    A quote from the Google Style guide: The C++ version targeted by this guide will advance (aggressively) over time. We could agree that some of our current guidelines need to be updated.
    At least from what I read, every clause in the guide comes with reasonings, pro and con. IMHO the ISO committee and the people behind the CCG are some of the most experienced in the field, so I'm assuming their reasoning is sound.

  5. addaleax commented on Sep 16, 2018

    @addaleax
    Member

    How about we start by adding this as a recommendation to read/look up from our style guide file? It’s a very comprehensive work, so while it certainly can help newcomers, we can’t expect them to be familiar with all of it.

  6. refack commented on Nov 13, 2018

    @refack
    ContributorAuthor

    Fixed by 0f8eaa4 (#23317)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++Issues and PRs that require attention from people who are familiar with C++.discussIssues opened for discussion and feedback.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions