mirror of
https://github.com/tiennm99/styleguide.git
synced 2026-08-06 04:23:51 +00:00
Update C++ style guide to 3.154:
- Add call_traits to the set of allowed boost libraries.
- Add an exception to the rule against default arguments to cover the useful
case of simulating variadic functions.
- Discourage the usage of ## in macros.
- Clarify example: it's acceptable to declare two parameters on one line even
if they don't all fit on that one line.
- Fix a typo ("make use symmetric spacing").
- Change bitwise AND to logical AND in a condition.
Update styleguide.xsl to 1.27:
- Change a bunch of SPANs into DIVs.
Update Python style guide to 2.15:
- Apply styleguide.xsl 1.27, changing a bunch of SPANs into DIVs.
This commit is contained in:
+37
-15
@@ -4,7 +4,7 @@
|
||||
|
||||
<p align="right">
|
||||
|
||||
Revision 3.146
|
||||
Revision 3.154
|
||||
</p>
|
||||
|
||||
|
||||
@@ -1581,7 +1581,8 @@ Tashana Landray
|
||||
|
||||
<STYLEPOINT title="Default Arguments">
|
||||
<SUMMARY>
|
||||
We do not allow default function parameters.
|
||||
We do not allow default function parameters, except in
|
||||
a few uncommon situations explained below.
|
||||
</SUMMARY>
|
||||
<BODY>
|
||||
<PROS>
|
||||
@@ -1600,10 +1601,23 @@ Tashana Landray
|
||||
the new code.
|
||||
</CONS>
|
||||
<DECISION>
|
||||
We require all arguments to be explicitly specified, to
|
||||
force programmers to consider the API and the values they are
|
||||
passing for each argument rather than silently accepting
|
||||
defaults they may not be aware of.
|
||||
<p>
|
||||
Except as described below, we require all arguments to be
|
||||
explicitly specified, to force programmers to consider the API
|
||||
and the values they are passing for each argument rather than
|
||||
silently accepting defaults they may not be aware of.
|
||||
</p>
|
||||
<p>
|
||||
One specific exception is when default arguments are used to
|
||||
simulate variable-length argument lists.
|
||||
</p>
|
||||
<CODE_SNIPPET>
|
||||
// Support up to 4 params by using a default empty AlphaNum.
|
||||
string StrCat(const AlphaNum &a,
|
||||
const AlphaNum &b = gEmptyAlphaNum,
|
||||
const AlphaNum &c = gEmptyAlphaNum,
|
||||
const AlphaNum &d = gEmptyAlphaNum);
|
||||
</CODE_SNIPPET>
|
||||
</DECISION>
|
||||
</BODY>
|
||||
</STYLEPOINT>
|
||||
@@ -2411,6 +2425,9 @@ Tashana Landray
|
||||
<li> Try not to use macros that expand to unbalanced C++
|
||||
constructs, or at least document that behavior well.
|
||||
</li>
|
||||
<li> Prefer not using <code>##</code> to generate function/class/variable
|
||||
names.
|
||||
</li>
|
||||
</ul>
|
||||
</BODY>
|
||||
</STYLEPOINT>
|
||||
@@ -2494,6 +2511,9 @@ Tashana Landray
|
||||
who might read and maintain code, we only allow an approved subset of
|
||||
Boost features. Currently, the following libraries are permitted:
|
||||
<ul>
|
||||
<li> <a href="http://www.boost.org/libs/utility/call_traits.htm">
|
||||
Call Traits</a> from <code>boost/call_traits.hpp</code>
|
||||
</li>
|
||||
<li> <a href="http://www.boost.org/libs/utility/compressed_pair.htm">
|
||||
Compressed Pair</a> from <code>boost/compressed_pair.hpp</code>
|
||||
</li>
|
||||
@@ -3493,8 +3513,7 @@ Tashana Landray
|
||||
If you have too much text to fit on one line:
|
||||
</p>
|
||||
<CODE_SNIPPET>
|
||||
ReturnType ClassName::ReallyLongFunctionName(Type par_name1,
|
||||
Type par_name2,
|
||||
ReturnType ClassName::ReallyLongFunctionName(Type par_name1, Type par_name2,
|
||||
Type par_name3) {
|
||||
DoSomething();
|
||||
...
|
||||
@@ -3882,15 +3901,18 @@ Tashana Landray
|
||||
<CODE_SNIPPET>
|
||||
if (this_one_thing > this_other_thing &&
|
||||
a_third_thing == a_fourth_thing &&
|
||||
yet_another & last_one) {
|
||||
yet_another && last_one) {
|
||||
...
|
||||
}
|
||||
</CODE_SNIPPET>
|
||||
<p>
|
||||
Note that both of the <code>&&</code> logical AND
|
||||
operators are the end of the line. Feel free to insert extra
|
||||
parentheses judiciously, because they can be very helpful in
|
||||
increasing readability when used appropriately.
|
||||
Note that when the code wraps in this example, both of
|
||||
the <code>&&</code> logical AND operators are at the
|
||||
end of the line. This is more common in Google code, though
|
||||
wrapping all operators at the beginning of the line is also
|
||||
allowed. Feel free to insert extra parentheses judiciously,
|
||||
because they can be very helpful in increasing readability
|
||||
when used appropriately.
|
||||
</p>
|
||||
</BODY>
|
||||
</STYLEPOINT>
|
||||
@@ -4166,7 +4188,7 @@ Tashana Landray
|
||||
vector<char *> x; // Spaces between type and pointer are
|
||||
// okay, but be consistent.
|
||||
set<list<string> > x; // C++ requires a space in > >.
|
||||
set< list<string> > x; // You may optionally make use
|
||||
set< list<string> > x; // You may optionally use
|
||||
// symmetric spacing in < <.
|
||||
</CODE_SNIPPET>
|
||||
</SUBSECTION>
|
||||
@@ -4377,7 +4399,7 @@ Tashana Landray
|
||||
<HR/>
|
||||
|
||||
<p align="right">
|
||||
Revision 3.146
|
||||
Revision 3.154
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user