diff --git a/cppguide.xml b/cppguide.xml index a3e45c2..480876c 100644 --- a/cppguide.xml +++ b/cppguide.xml @@ -4,7 +4,7 @@
-Revision 3.188 +Revision 3.199
@@ -209,7 +209,6 @@ Tashana Landray definitions of the classes they use, and usually have to include several header files. -Foo in your source file, you
should bring in a definition for Foo yourself,
@@ -383,11 +382,13 @@ Tashana Landray
.h files.
- The preferred ordering reduces hidden dependencies. We want
- every header file to be compilable on its own. The easiest
- way to achieve this is to make sure that every one of them is
- the first .h file #included in some
- .cc.
+ With the preferred ordering, if dir/foo2.h
+ omits any necessary includes, the build of
+ dir/foo.cc or
+ dir/foo_test.cc will break.
+ Thus, this rule ensures that build breaks show up first
+ for the people working on these files, not for innocent people
+ in other packages.
Use namespaces according to the policy described below.
+ Terminate namespaces with comments as shown in the given examples.
dir/foo.cc and
@@ -412,7 +413,6 @@ Tashana Landray
#include <sys/types.h>
#include <unistd.h>
-
#include <hash_map>
#include <vector>
@@ -468,6 +468,7 @@ Tashana Landray
//
- namespace.
+ an unnamed namespace.
.h
@@ -1239,7 +1238,7 @@ Tashana Landray
An interface class can never be directly instantiated
because of the pure virtual method(s) it declares. To make
sure all implementations of the interface can be destroyed
- correctly, they must also declare a virtual destructor (in
+ correctly, the interface must also declare a virtual destructor (in
an exception to the first rule, this should not be pure). See
Stroustrup, The C++ Programming Language, 3rd
edition, section 12.4 for details.
@@ -1574,14 +1573,24 @@ Tashana Landray
non-const reference parameters.
- One case when you might want an input parameter to be a
- const pointer is if you want to emphasize that the
- argument is not copied, so it must exist for the lifetime of the
- object; it is usually best to document this in comments as
- well. STL adapters such as bind2nd and
- mem_fun do not permit reference parameters, so
- you must declare functions with pointer parameters in these
- cases, too.
+
+ However, there are some instances where using const T*
+ is preferable to const T& for input parameters. For
+ example:
+
+ You want to pass in NULL.
+
+ The function saves a pointer or reference to the input.
+
+
+ Remember that most of the time input parameters are going to be
+ specified as const T&. Using const T*
+ instead communicates to the reader that the input is somehow treated
+ differently. So if you choose const T* rather than
+ const T&, do so for a concrete reason; otherwise it
+ will likely confuse readers by making them look for an explanation
+ that doesn't exist.
+