From 8b0c7b011d62a34d67ec92001a453466cf51d3d6 Mon Sep 17 00:00:00 2001 From: parmaski <89462537+parmaski@users.noreply.github.com> Date: Mon, 17 Oct 2022 09:35:24 +0900 Subject: [PATCH 1/2] Add tag and namespace, if appropriate --- cppguide.html | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/cppguide.html b/cppguide.html index a7f32245a..9076a3e01 100644 --- a/cppguide.html +++ b/cppguide.html @@ -958,7 +958,7 @@

Common patterns

@@ -2133,9 +2133,9 @@

Rvalue References

objects. The syntax is similar to traditional reference syntax. For example, void f(std::string&& s); declares a function whose argument is an -rvalue reference to a std::string.

+rvalue reference to a std::string.

-

When the token '&&' is applied to +

When the token && is applied to an unqualified template argument in a function parameter, special template argument deduction rules apply. Such a reference is called forwarding reference.

@@ -2227,7 +2227,7 @@

Friends

Friends extend, but do not break, the encapsulation boundary of a class. In some cases this is better than -making a member public when you want to give only one +making a member public when you want to give only one other class access to it. However, most classes should interact with other classes solely through their public members.

@@ -2533,8 +2533,8 @@

Casting

initialization for conversion of arithmetic types like int64_t y = int64_t{1} << 42. Do not use cast formats like (int)x unless the cast is to -void. You may use cast formats like `T(x)` only when -`T` is a class type.

+void. You may use cast formats like T(x) only when +T is a class type.

C++ introduced a @@ -2797,7 +2797,7 @@

Use of const

  • Declare methods to be const unless they alter the logical state of the object (or enable the user to modify - that state, e.g., by returning a non-const reference, but that's + that state, e.g., by returning a non-const reference, but that's rare), or they can't safely be invoked concurrently.
  • @@ -2850,9 +2850,9 @@

    Use of constexpr

    calls.

    -

    Prematurely marking something as constexpr may cause +

    Prematurely marking something as constexpr may cause migration problems if later on it has to be downgraded. -Current restrictions on what is allowed in constexpr +Current restrictions on what is allowed in constexpr functions and constructors may invite obscure workarounds in these definitions.

    @@ -3918,7 +3918,7 @@

    Aliases

    Like other declarations, aliases declared in a header file are part of that header's public API unless they're in a function definition, in the private portion of a class, - or in an explicitly-marked internal namespace. Aliases in such areas or in .cc files are + or in an explicitly-marked internal namespace. Aliases in such areas or in .cc files are implementation details (because client code can't refer to them), and are not restricted by this rule.

    @@ -3979,8 +3979,8 @@

    Aliases

    } // namespace mynamespace -

    However, local convenience aliases are fine in function definitions, private sections of - classes, explicitly marked internal namespaces, and in .cc files:

    +

    However, local convenience aliases are fine in function definitions, private sections of + classes, explicitly marked internal namespaces, and in .cc files:

    // In a .cc file
     using ::foo::Bar;
    @@ -4202,7 +4202,7 @@ 

    Struct Data Members

    Constant Names

    -

    Variables declared constexpr or const, and whose value is fixed for +

    Variables declared constexpr or const, and whose value is fixed for the duration of the program, are named with a leading "k" followed by mixed case. Underscores can be used as separators in the rare cases where capitalization cannot be used for separation. For example:

    @@ -4455,7 +4455,7 @@

    Function Declarations

    preceding it that describe what the function does and how to use it. These comments may be omitted only if the function is simple and obvious (e.g., simple accessors for obvious properties of the class). -Private methods and functions declared in `.cc` files are not exempt. +Private methods and functions declared in .cc files are not exempt. Function comments should be written with an implied subject of This function and should start with the verb phrase; for example, "Opens the file", rather than "Open the file". In general, these comments do not From eb77c1b552a9b09c3538b5d2b8cd5d224473610d Mon Sep 17 00:00:00 2001 From: parmaski <89462537+parmaski@users.noreply.github.com> Date: Mon, 17 Oct 2022 09:49:43 +0900 Subject: [PATCH 2/2] Add necessary

    and remove unnecessary

    --- cppguide.html | 84 ++++++++------------------------------------------- 1 file changed, 13 insertions(+), 71 deletions(-) diff --git a/cppguide.html b/cppguide.html index 9076a3e01..8404516b3 100644 --- a/cppguide.html +++ b/cppguide.html @@ -174,9 +174,8 @@

    C++ Version

    Do not use non-standard extensions.

    -
    Consider portability to other environments -before using features from C++14 and C++17 in your project. -
    +

    Consider portability to other environments +before using features from C++14 and C++17 in your project.

    Header Files

    @@ -230,15 +229,11 @@

    The #define Guard

    <PROJECT>_<PATH>_<FILE>_H_.

    - - -

    To guarantee uniqueness, they should be based on the full path in a project's source tree. For example, the file foo/src/bar/baz.h in project foo should have the following guard:

    -
    #ifndef FOO_BAR_BAZ_H_
     #define FOO_BAR_BAZ_H_
    @@ -436,14 +431,11 @@ 

    Names and Order of Includes

  • A blank line
  • -
  • Other libraries' .h files.
  • A blank line
  • -
    -
  • - Your project's .h +
  • Your project's .h files.
  • @@ -1180,8 +1172,8 @@

    Implicit Conversions

    Func({42, 3.14});  // Error
     
    -This kind of code isn't technically an implicit conversion, but the -language treats it as one as far as explicit is concerned. +

    This kind of code isn't technically an implicit conversion, but the +language treats it as one as far as explicit is concerned.

      @@ -1961,15 +1953,9 @@

      Trailing Return Type Syntax

      Google-Specific Magic

      - - -

      There are various tricks and utilities that we use to make C++ code more robust, and various ways we use C++ that may differ from what you see elsewhere.

      -
      - -

      Ownership and Smart Pointers

      @@ -2108,18 +2094,12 @@

      cpplint

      positives and false negatives, but it is still a valuable tool.

      - - -

      Some projects have instructions on how to run cpplint.py from their project tools. If the project you are contributing to does not, you can download cpplint.py separately.

      -
      - -

      Other C++ Features

      @@ -2243,14 +2223,10 @@

      Exceptions

      nested functions, without the obscuring and error-prone bookkeeping of error codes. - - -
    • Exceptions are used by most other modern languages. Using them in C++ would make it more consistent with Python, Java, and the C++ that others are familiar with.
    • -
    • Some third-party C++ libraries use exceptions, and turning them off internally makes it harder to @@ -3746,9 +3722,6 @@

      Boost

      - - -

      In order to maintain a high level of readability for all contributors who might read and maintain code, we only allow an approved subset of Boost features. @@ -3821,10 +3794,6 @@

      Boost

      We are actively considering adding other Boost features to the list, so this list may be expanded in the future.

      -
      - - -

      Other C++ Features

      @@ -4242,10 +4211,10 @@

      Function Names

      Namespace Names

      -Namespace names are all lower-case, with words separated by underscores. +

      Namespace names are all lower-case, with words separated by underscores. Top-level namespace names are based on the project name . Avoid collisions -between nested namespaces and well-known top-level namespaces. +between nested namespaces and well-known top-level namespaces.

      The name of a top-level namespace should usually be the name of the project or team whose code is contained in that @@ -4374,26 +4343,19 @@

      Comment Style

      File Comments

      -

      Start each file with license boilerplate.

      -

      File comments describe the contents of a file. If a file declares, implements, or tests exactly one abstraction that is documented by a comment at the point of declaration, file comments are not required. All other files must have file comments.

      -

      Legal Notice and Author -Line

      - +

      Legal Notice and Author Line

      - -

      Every file should contain license boilerplate. Choose the appropriate boilerplate for the license used by the project (for example, Apache 2.0, BSD, LGPL, GPL).

      -

      If you make significant changes to a file with an author line, consider deleting the author line. @@ -4652,8 +4614,8 @@

      Don'ts

      }
    -Self-describing code doesn't need a comment. The comment from -the example above would be obvious: +

    Self-describing code doesn't need a comment. The comment from +the example above would be obvious:

    if (!IsAlreadyProcessed(element)) {
       Process(element);
    @@ -4699,14 +4661,10 @@ 

    TODO Comments

    a TODO with a name, it is almost always your name that is given.

    - - -
    // TODO(kl@gmail.com): Use a "*" here for concatenation operator.
     // TODO(Zeke) change this to use relations.
     // TODO(bug 12345): remove the "Last visitors" feature.
     
    -

    If your TODO is of the form "At a future date do something" make sure that you either include a @@ -4728,26 +4686,18 @@

    Formatting

    they can all read and understand everyone's code easily.

    - - -

    To help you format code correctly, we've created a settings file for emacs.

    -

    Line Length

    Each line of text in your code should be at most 80 characters long.

    - - -

    We recognize that this rule is controversial, but so much existing code already adheres to it, and we feel that consistency is important.

    -

    Those who favor this rule @@ -5211,7 +5161,6 @@

    Loops and Switch Statements

    -
    switch (var) {
       case 0: {  // 2 space indent
         ...      // 4 space indent
    @@ -5226,7 +5175,6 @@ 

    Loops and Switch Statements

    } }
    -

    Fall-through from one case label to another must be annotated using the @@ -5327,9 +5275,10 @@

    Pointer and Reference Expressions

    -It is allowed (if unusual) to declare multiple variables in the same +

    It is allowed (if unusual) to declare multiple variables in the same declaration, but it is disallowed if any of those have pointer or -reference decorations. Such declarations are easily misread. +reference decorations. Such declarations are easily misread.

    +
    // Fine if helpful for readability.
     int x, y;
     
    @@ -5711,9 +5660,6 @@

    Exceptions to the Rules

    However, like all good rules, these sometimes have exceptions, which we discuss here.

    - - -

    Existing Non-conformant Code

    You may diverge from the rules when dealing with code that @@ -5728,10 +5674,6 @@

    Existing Non-conformant Code

    the code. Remember that consistency includes local consistency, too.

    -
    - - -

    Windows Code

    Windows