From 0124f309e4a147df614035a11549abba143679d7 Mon Sep 17 00:00:00 2001 From: Titus Winters Date: Wed, 6 Jan 2016 16:09:22 -0500 Subject: [PATCH] Update to current. Most significant updates: * Casting (for arithmetic types, maybe use {}s) * Namespaces * Aliases --- cppguide.html | 301 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 199 insertions(+), 102 deletions(-) diff --git a/cppguide.html b/cppguide.html index d4993d1..21a21f3 100644 --- a/cppguide.html +++ b/cppguide.html @@ -579,6 +579,7 @@ below. Terminate namespaces with comments as shown in the given examples. See also the rules on Namespace Names.

+

Unnamed Namespaces

@@ -679,31 +680,12 @@ using namespace foo; -
  • You may use a using-declaration - anywhere in a .cc file (including in - the global namespace), and in functions, - methods, classes, or within internal namespaces in - .h files.

    - -

    Do not use using-declarations in .h - files except in explicitly marked internal-only - namespaces, because anything imported into a namespace - in a .h file becomes part of the public +

  • Do not use Namespace aliases at namespace scope + in header files except in explicitly marked + internal-only namespaces, because anything imported into a namespace + in a header file becomes part of the public API exported by that file.

    -
    // OK in .cc files.
    -// Must be in a function, method, internal namespace, or
    -// class in .h files.
    -using ::foo::bar;
    -
    -
  • - -
  • Namespace aliases are allowed anywhere where - a using-declaration is allowed. In particular, - namespace aliases should not be used at namespace scope - in .h files except in explicitly marked - internal-only namespaces.

    -
    // Shorten access to some commonly used names in .cc files.
     namespace baz = ::foo::bar::baz;
     
    @@ -871,13 +853,14 @@ for static variables are called is only partially specified in C++ and can even change from build to build, which can cause bugs that are difficult to find. Therefore in addition to banning globals of class type, -we do not allow static POD variables to be initialized +we do not allow namespace-scope static variables to be initialized with the result of a function, unless that function (such as getenv(), or getpid()) does not itself depend on any -other globals. (This prohibition does not apply to a static -variable within function scope, since its initialization -order is well-defined and does not occur until control -passes through its declaration.)

    +other globals. However, a static POD variable within +function scope may be initialized with the result of a +function, since its initialization order is well-defined +and does not occur until control passes through its +declaration.

    Likewise, global and static variables are destroyed when the program terminates, regardless of whether the @@ -980,9 +963,9 @@ of the constructor.

    IsValid() state checking mechanism (or similar) which is easy to forget to call.
  • -
  • You cannot take address of a constructor, so whatever work is done in - the constructor cannot easily be handed off to, for example, another - thread.
  • +
  • You cannot take the address of a constructor, so whatever work + is done in the constructor cannot easily be handed off to, for + example, another thread.
  • @@ -1730,7 +1713,7 @@ are empty, omit them.

    be in the following order: