diff --git a/cppguide.xml b/cppguide.xml index e87b36f..a0c2abf 100644 --- a/cppguide.xml +++ b/cppguide.xml @@ -4,7 +4,7 @@
-Revision 3.245 +Revision 3.260
@@ -737,6 +737,14 @@ Tashana Landray
Note that gcc implements for (int i = 0; i
< 10; ++i)
correctly (the scope of i
is
@@ -779,8 +787,6 @@ Tashana Landray
Static or global variables of class type are forbidden: they cause
hard-to-find bugs due to indeterminate order of construction and
destruction.
- However, such variables are allowed if they are constexpr
:
- they have no dynamic initialization or destruction.
@@ -967,6 +973,12 @@ Tashana Landray exceptions. Such exceptions should be clearly marked with comments.
+
+ Finally, constructors that take only an initializer_list may be
+ non-explicit. This is to permit construction of your type using the
+ assigment form for brace init lists (i.e. MyType m = {1, 2}
+
).
+
scoped_ptr
- is great. You should only use std::tr1::shared_ptr
+ If you actually need pointer semantics, unique_ptr
+ is great, and scoped_ptr
is fine if you need to support
+ older versions of C++. You should only use shared_ptr
with a non-const referent when it is truly necessary to share ownership
of an object (e.g. inside an STL container). You should never use
auto_ptr
.
@@ -1481,11 +1494,15 @@ Tashana Landray
unique_ptr
scoped_ptr
unique_ptr
unless C++03 compatibility is
+ required.auto_ptr
unique_ptr
instead, if possible.shared_ptr
shared_ptr<const
@@ -2162,8 +2179,6 @@ Tashana Landray
Use const
whenever it makes sense.
- With C++11,
- constexpr
is a better choice for some uses of const.
@@ -2248,51 +2263,6 @@ Tashana Landray
-
-
- In C++11, use constexpr
- to define true constants or to ensure constant initialization.
-
-
-
- Some variables can be declared constexpr
- to indicate the variables are true constants,
- i.e. fixed at compilation/link time.
- Some functions and constructors can be declared constexpr
- which enables them to be used
- in defining a constexpr
variable.
-
-
- Use of constexpr
enables
- definition of constants with floating-point expressions
- rather than just literals;
- definition of constants of user-defined types; and
- definition of constants with function calls.
-
-
- 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 functions and constructors
- may invite obscure workarounds in these definitions.
-
-
-
- constexpr
definitions enable a more robust
- specification of the constant parts of an interface.
- Use constexpr
to specify true constants
- and the functions that support their definitions.
- Avoid complexifying function definitions to enable
- their use with constexpr
.
- Do not use constexpr
to force inlining.
-
-
-
-
-
-
-
Of the built-in C++ integer types, the only one used
@@ -2735,9 +2705,7 @@ Tashana Landray
The interaction between auto
and C++11
- brace-initialization can be confusing. (C++11 brace-initialization
- isn't an approved feature, but this may become relevant when and
- if it is permitted.) The declarations
+ brace-initialization can be confusing. The declarations
auto x(3); // Note: parentheses.
auto y{3}; // Note: curly braces.
@@ -2757,7 +2725,8 @@ Tashana Landray
auto
is permitted, for local variables only.
Do not use auto
for file-scope or namespace-scope
- variables, or for class members.
+ variables, or for class members. Never assign a braced initializer list
+ to an auto
-typed variable.
The auto
keyword is also used in an unrelated
C++11 feature: it's part of the syntax for a new kind of
function declaration with a trailing return type. Function
@@ -2766,6 +2735,88 @@ Tashana Landray