Skip to content

Commit 3adbbcc

Browse files
pkastingCommit bot
authored and
Commit bot
committed
Allow <algorithm>.
This also makes the language consistent for the three "allow <library>" items and removes some more-specific entries that are subsumed by the more general items. BUG=none TEST=none Review URL: https://codereview.chromium.org/1662933002 Cr-Commit-Position: refs/heads/master@{#373418}
1 parent e182ebe commit 3adbbcc

File tree

1 file changed

+40
-36
lines changed

1 file changed

+40
-36
lines changed

styleguide/c++/c++11.html

+40-36
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,26 @@ <h2 id="whitelist"><a name="library-whitelist"></a>C++11 Allowed Library Feature
334334
<td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/16V7fmtbzok">Discussion thread</a></td>
335335
</tr>
336336

337+
<tr>
338+
<td>Algorithms</td>
339+
<td>All C++11 features in <code>&lt;algorithm&gt;</code>:<br/>
340+
<code>all_of</code>, <code>any_of</code>, <code>none_of</code><br/>
341+
<code>find_if_not</code><br/>
342+
<code>copy_if</code>, <code>copy_n</code><br/>
343+
<code>move</code>, <code>move_backward</code> (see note)<br/>
344+
<code>shuffle</code><br/>
345+
<code>is_partitioned</code>, <code>partition_copy</code>, <code>partition_point</code><br/>
346+
<code>is_sorted</code>, <code>is_sorted_until</code><br/>
347+
<code>is_heap</code>, <code>is_heap_until</code><br/>
348+
<code>minmax</code>, <code>minmax_element</code><br/>
349+
<code>is_permutation<br/>
350+
</td>
351+
<td>Safe and performant implementations of common algorithms</td>
352+
<td><a href="http://en.cppreference.com/w/cpp/header/algorithm"><code>&lt;algorithm&gt;</code></a></td>
353+
<td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/UJQk8S1IuHk">Discussion thread</a><br/>
354+
Note that &lt;algorithm&gt; contains a range-based <code>move</code> method. This is allowed, but because people may confuse it with the single-arg <code>std::move</code>, there is often a way to write code without it that is more readable. <a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/8WzmtYrZvQ8'>Discussion thread</a></td>
355+
</tr>
356+
337357
<tr>
338358
<td>Begin and End Non-Member Functions</td>
339359
<td><code>std::begin()</code> and <code>std::end()</code></td>
@@ -381,6 +401,18 @@ <h2 id="whitelist"><a name="library-whitelist"></a>C++11 Allowed Library Feature
381401
<td>General use of <code>std::tuple</code>, and <code>std::tie</code> for unpacking or multiple assignments is still not allowed. <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/3DZ64dIMRTY/discussion">Discussion thread</a></td>
382402
</tr>
383403

404+
<tr>
405+
<td>Math functions</td>
406+
<td>All C++11 features in <code>&lt;cmath&gt;</code>, e.g.:<br/>
407+
<code>INFINITY</code>, <code>NAN</code>, <code>FP_NAN</code><br/>
408+
<code>float_t</code>, <code>double_t</code><br/>
409+
<code>fmax</code>, <code>fmin</code>, <code>trunc</code>, <code>round</code><br/>
410+
<code>isinf</code>, <code>isnan</code><br/></td>
411+
<td>Useful for math-related code</td>
412+
<td><a href="http://en.cppreference.com/w/cpp/header/cmath"><code>&lt;cmath&gt;</code></a></td>
413+
<td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/P-1bFBXMeUk">Discussion thread</a></td>
414+
</tr>
415+
384416
<tr>
385417
<td>Move Iterator Adaptor</td>
386418
<td><code>std::make_move_iterator()</code></td>
@@ -397,31 +429,20 @@ <h2 id="whitelist"><a name="library-whitelist"></a>C++11 Allowed Library Feature
397429
<td><a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/x_dWFxJFdbM'>Discussion thread</a></td>
398430
</tr>
399431

400-
<tr>
401-
<td>Range Move</td>
402-
<td><code>std::move()</code></td>
403-
<td>Moves contents of an iterator range to a different iterator. This is a counterpart of std::copy that applies std::move() to each element.</td>
404-
<td><a href="http://en.cppreference.com/w/cpp/algorithm/move"><code>std::move</code> reference</a></td>
405-
<td>This is allowed, but there is almost always a way to write code without using this version of std::move. Not using it usually results in cleaner, easier to read, and less confusing code. <a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/8WzmtYrZvQ8'>Discussion thread</a></td>
406-
</tr>
407-
408432
<tr>
409433
<td>Type Traits</td>
410-
<td>Class templates within <code>&lt;type_traits&gt;</code></td>
434+
<td>All C++11 features in <code>&lt;type_traits&gt;</code> except for aligned storage (see separate item), e.g.:<br/>
435+
<code>integral_constant</code><br/>
436+
<code>is_floating_point</code>, <code>is_rvalue_reference</code>, <code>is_scalar</code><br/>
437+
<code>is_const</code>, <code>is_pod</code>, <code>is_unsigned</code><br/>
438+
<code>is_default_constructible</code>, <code>is_move_constructible</code>, <code>is_copy_assignable</code><br/>
439+
<code>enable_if</code>, <code>conditional</code>, <code>result_of</code><br/>
440+
</td>
411441
<td>Allows compile-time inspection of the properties of types</td>
412-
<td><a href="http://en.cppreference.com/w/cpp/header/type_traits">
413-
Standard library header &lt;type_traits&gt;</a></td>
442+
<td><a href="http://en.cppreference.com/w/cpp/header/type_traits">&lt;type_traits&gt;</a></td>
414443
<td>Note that not all type traits are available on all platforms (eg std::underlying_type doesn't work in libstdc++4.6). Use judiciously. <a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/vCxo4tZNd_M'>Discussion thread</a></td>
415444
</tr>
416445

417-
<tr>
418-
<td>Types, functions, and constants from <code>&lt;cmath&gt;</code></td>
419-
<td><code>std::round()</code>, <code>std::isnan()</code>, and others</td>
420-
<td>Useful for math-related code</td>
421-
<td><a href="http://en.cppreference.com/w/cpp/header/cmath"><code>&lt;cmath&gt;</code></a></td>
422-
<td>Anything in <code>&lt;cmath&gt;</code> is allowed. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/P-1bFBXMeUk">Discussion thread</a></td>
423-
</tr>
424-
425446
<tr>
426447
<td>Unordered Associative Containers</td>
427448
<td><code>std::unordered_set</code>, <code>std::unordered_map</code>,
@@ -902,14 +923,6 @@ <h3 id="blacklist_stdlib_review"><a name="library-review"></a>C++11 Standard Lib
902923
<td></td>
903924
</tr>
904925

905-
<tr>
906-
<td>Heap Validation</td>
907-
<td><code>std::is_heap()</code></td>
908-
<td>Checks whether an iterator range is in fact a heap</td>
909-
<td>TODO: documentation link</td>
910-
<td></td>
911-
</tr>
912-
913926
<tr>
914927
<td>Iterator Operators</td>
915928
<td><code>std::next()</code> and <code>std::prev()</code></td>
@@ -1001,15 +1014,6 @@ <h3 id="blacklist_stdlib_review"><a name="library-review"></a>C++11 Standard Lib
10011014
<td></td>
10021015
</tr>
10031016

1004-
<tr>
1005-
<td>STL Algorithms</td>
1006-
<td>Functions within <code>&lt;algorithm&gt;</code>.</td>
1007-
<td>Enhancements to the set of STL algorithms</td>
1008-
<td>See the <a href="http://en.cppreference.com/w/cpp/algorithm">
1009-
Algorithms library</a> for a complete list.</td>
1010-
<td></td>
1011-
</tr>
1012-
10131017
<tr>
10141018
<td>System Errors</td>
10151019
<td><code>&lt;system_error&gt;</code></td>

0 commit comments

Comments
 (0)