@@ -754,6 +754,12 @@ <h3 id="Namespaces">Namespaces</h3>
754754 < li > < p > Single-line nested namespace declarations
755755
756756 are preferred in new code, but are not required.</ p >
757+ < pre class ="goodcode "> namespace my_project::my_component {
758+
759+ ...
760+
761+ } // namespace my_project::my_component
762+ </ pre >
757763 </ li >
758764</ ul >
759765
@@ -1519,11 +1525,12 @@ <h3 id="Structs_vs._Classes">Structs vs. Classes</h3>
15191525
15201526< p > < code > structs</ code > should be used for passive objects that carry
15211527data, and may have associated constants. All fields must be public. The
1522- struct must not have invariants that imply relationships between
1528+ struct type itself must not have invariants that imply relationships between
15231529different fields, since direct user access to those fields may
1524- break those invariants. Constructors, destructors, and helper methods may
1525- be present; however, these methods must not require or enforce any
1526- invariants.</ p >
1530+ break those invariants, but users of a struct may have requirements and
1531+ guarantees on particular uses of it. Constructors, destructors, and helper
1532+ methods may be present; however, these methods must not require or enforce
1533+ any invariants.</ p >
15271534
15281535< p > If more functionality or invariants are required, or struct has wide visibility and expected to
15291536evolve, then a < code > class</ code > is more appropriate. If in doubt, make it a < code > class</ code > .
@@ -1927,8 +1934,8 @@ <h3 id="Function_Overloading">Function Overloading</h3>
19271934
19281935< pre class ="neutralcode "> class MyClass {
19291936 public:
1930- void Analyze(const std::string &text);
1931- void Analyze(const char * text, size_t textlen);
1937+ void Analyze(const std::string& text);
1938+ void Analyze(const char* text, size_t textlen);
19321939};
19331940</ pre >
19341941
@@ -2021,13 +2028,13 @@ <h3 id="trailing_return">Trailing Return Type Syntax</h3>
20212028< p class ="definition "> </ p >
20222029< p > C++ allows two different forms of function declarations. In the older
20232030 form, the return type appears before the function name. For example:</ p >
2024- < pre class ="neutralcode "> int foo (int x);
2031+ < pre class ="neutralcode "> int Foo (int x);
20252032</ pre >
20262033< p > The newer form uses the < code > auto</ code >
20272034 keyword before the function name and a trailing return type after
20282035 the argument list. For example, the declaration above could
20292036 equivalently be written:</ p >
2030- < pre class ="neutralcode "> auto foo (int x) -> int;
2037+ < pre class ="neutralcode "> auto Foo (int x) -> int;
20312038</ pre >
20322039< p > The trailing return type is in the function's scope. This doesn't
20332040 make a difference for a simple case like < code > int</ code > but it matters
@@ -2046,17 +2053,16 @@ <h3 id="trailing_return">Trailing Return Type Syntax</h3>
20462053 particularly true when the return type depends on template parameters.
20472054 For example:</ p >
20482055 < pre class ="neutralcode "> template <typename T, typename U>
2049- auto add (T t, U u) -> decltype(t + u);
2056+ auto Add (T t, U u) -> decltype(t + u);
20502057 </ pre >
20512058 versus
20522059 < pre class ="neutralcode "> template <typename T, typename U>
2053- decltype(declval<T&>() + declval<U&>()) add (T t, U u);
2060+ decltype(declval<T&>() + declval<U&>()) Add (T t, U u);
20542061 </ pre >
20552062
20562063< p class ="cons "> </ p >
2057- < p > Trailing return type syntax is relatively new and it has no
2058- analogue in C++-like languages such as C and Java, so some readers may
2059- find it unfamiliar.</ p >
2064+ < p > Trailing return type syntax has no analogue in C++-like languages
2065+ such as C and Java, so some readers may find it unfamiliar.</ p >
20602066< p > Existing codebases have an enormous number of function
20612067 declarations that aren't going to get changed to use the new syntax,
20622068 so the realistic choices are using the old syntax only or using a mixture
@@ -2169,8 +2175,8 @@ <h3 id="Ownership_and_Smart_Pointers">Ownership and Smart Pointers</h3>
21692175 where the resource releases take place.</ li >
21702176
21712177 < li > < code > std::unique_ptr</ code > expresses ownership
2172- transfer using move semantics, which are
2173- relatively new and may confuse some programmers.</ li >
2178+ transfer using move semantics, which can be complex and
2179+ may confuse some programmers.</ li >
21742180
21752181 < li > Shared ownership can be a tempting alternative to
21762182 careful ownership design, obfuscating the design of a
@@ -2925,7 +2931,7 @@ <h3 id="Use_of_const">Use of const</h3>
29252931
29262932< h4 > Where to put the const</ h4 >
29272933
2928- < p > Some people favor the form < code > int const * foo</ code >
2934+ < p > Some people favor the form < code > int const* foo</ code >
29292935to < code > const int* foo</ code > . They argue that this is
29302936more readable because it's more consistent: it keeps the
29312937rule that < code > const</ code > always follows the object
@@ -4493,10 +4499,10 @@ <h3 id="Type_Names">Type Names</h3>
44934499struct UrlTableProperties { ...
44944500
44954501// typedefs
4496- typedef hash_map<UrlTableProperties *, std::string> PropertiesMap;
4502+ typedef hash_map<UrlTableProperties*, std::string> PropertiesMap;
44974503
44984504// using aliases
4499- using PropertiesMap = hash_map<UrlTableProperties *, std::string>;
4505+ using PropertiesMap = hash_map<UrlTableProperties*, std::string>;
45004506
45014507// enums
45024508enum class UrlTableError { ...
@@ -4696,8 +4702,8 @@ <h3 id="Naming_Aliases">Aliases</h3>
46964702
46974703< h3 id ="Exceptions_to_Naming_Rules "> Exceptions to Naming Rules</ h3 >
46984704
4699- < p > If you are naming something that is analogous to an
4700- existing C or C++ entity then you can follow the existing
4705+ < p > If you are naming something that is analogous to an existing C or C++
4706+ entity ( or a Rust entity via interop), then you can follow the existing
47014707naming convention scheme.</ p >
47024708
47034709< dl >
@@ -5056,9 +5062,10 @@ <h3 id="TODO_Comments">TODO Comments</h3>
50565062< p > < code > TODO</ code > s should include the string
50575063< code > TODO</ code > in all caps, followed by the bug ID, name, e-mail address, or other identifier
50585064of the person or issue with the best context
5059- about the problem referenced by the < code > TODO</ code > .
5065+ about the problem referenced by the < code > TODO</ code > .</ p >
5066+ < p > Recommended styles are (in order of preference):</ p >
50605067
5061- </ p > < pre class ="goodcode "> // TODO: bug 12345678 - Remove this after the 2047q4 compatibility window expires.
5068+ < pre class ="goodcode "> // TODO: bug 12345678 - Remove this after the 2047q4 compatibility window expires.
50625069// TODO: example.com/my-design-doc - Manually fix up this code the next time it's touched.
50635070// TODO(bug 12345678): Update this list after the Foo service is turned down.
50645071// TODO(John): Use a "\*" here for concatenation operator.
@@ -5979,8 +5986,8 @@ <h4>Templates and Casts</h4>
59795986std::vector<std::string> x;
59805987y = static_cast<char*>(x);
59815988
5982- // Spaces between type and pointer are OK, but be consistent .
5983- std::vector<char *> x;
5989+ // No spaces between type and pointer.
5990+ std::vector<char*> x;
59845991</ pre >
59855992
59865993< h3 id ="Vertical_Whitespace "> Vertical Whitespace</ h3 >
@@ -6048,7 +6055,7 @@ <h3 id="Windows_Code">Windows Code</h3>
60486055 and encouraged, that you use these types when calling
60496056 Windows API functions. Even so, keep as close as you
60506057 can to the underlying C++ types. For example, use
6051- < code > const TCHAR *</ code > instead of
6058+ < code > const TCHAR*</ code > instead of
60526059 < code > LPCTSTR</ code > .</ li >
60536060
60546061 < li > When compiling with Microsoft Visual C++, set the
0 commit comments