Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: styleguide/c++/c++11.html

Issue 1662933002: Allow <algorithm>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove special char Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright 2014 The Chromium Authors. All rights reserved. 3 Copyright 2014 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 <html> 7 <html>
8 <head> 8 <head>
9 <meta charset="utf-8"> 9 <meta charset="utf-8">
10 <title>C++11 use in Chromium</title> 10 <title>C++11 use in Chromium</title>
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 328
329 <tr> 329 <tr>
330 <td>Access to underlying <code>std::vector</code> data</td> 330 <td>Access to underlying <code>std::vector</code> data</td>
331 <td><code>v.data()</code></td> 331 <td><code>v.data()</code></td>
332 <td>Returns a pointer to a <code>std::vector</code>'s underlying data, accountin g for empty vectors.</td> 332 <td>Returns a pointer to a <code>std::vector</code>'s underlying data, accountin g for empty vectors.</td>
333 <td><a href="http://en.cppreference.com/w/cpp/container/vector/data">std::vector ::data</a></td> 333 <td><a href="http://en.cppreference.com/w/cpp/container/vector/data">std::vector ::data</a></td>
334 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/16V7fmtb zok">Discussion thread</a></td> 334 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/16V7fmtb zok">Discussion thread</a></td>
335 </tr> 335 </tr>
336 336
337 <tr> 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;algori thm&gt;</code></a></td>
353 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/UJQk8S1I uHk">Discussion thread</a><br/>
354 Note that &lt;algorithm&gt; contains a range-based <code>move</code> method. Th is 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/8WzmtYrZv Q8'>Discussion thread</a></td>
355 </tr>
356
357 <tr>
338 <td>Begin and End Non-Member Functions</td> 358 <td>Begin and End Non-Member Functions</td>
339 <td><code>std::begin()</code> and <code>std::end()</code></td> 359 <td><code>std::begin()</code> and <code>std::end()</code></td>
340 <td>Allows use of free functions on any container, including 360 <td>Allows use of free functions on any container, including
341 fixed-size arrays</td> 361 fixed-size arrays</td>
342 <td><a href="http://en.cppreference.com/w/cpp/iterator/begin"> 362 <td><a href="http://en.cppreference.com/w/cpp/iterator/begin">
343 std::begin</a> and 363 std::begin</a> and
344 <a href="http://en.cppreference.com/w/cpp/iterator/end"> 364 <a href="http://en.cppreference.com/w/cpp/iterator/end">
345 std::end</a></td> 365 std::end</a></td>
346 <td>Useful for fixed-size arrays. <a href="https://groups.google.com/a/chromium. org/d/topic/cxx/5iFNE8P5qT4/discussion">Discussion thread</a></td> 366 <td>Useful for fixed-size arrays. <a href="https://groups.google.com/a/chromium. org/d/topic/cxx/5iFNE8P5qT4/discussion">Discussion thread</a></td>
347 </tr> 367 </tr>
(...skipping 27 matching lines...) Expand all
375 395
376 <tr> 396 <tr>
377 <td>Lexicographical struct comparison</td> 397 <td>Lexicographical struct comparison</td>
378 <td><code>tie(a, b, c) &lt;<br>&nbsp; tie(rhs.a, rhs.b, rhs.c)</code></td> 398 <td><code>tie(a, b, c) &lt;<br>&nbsp; tie(rhs.a, rhs.b, rhs.c)</code></td>
379 <td>Idiom for <code>operator&lt;</code> implementation</td> 399 <td>Idiom for <code>operator&lt;</code> implementation</td>
380 <td><a href="http://en.cppreference.com/w/cpp/utility/tuple/tie">std::tie</a></t d> 400 <td><a href="http://en.cppreference.com/w/cpp/utility/tuple/tie">std::tie</a></t d>
381 <td>General use of <code>std::tuple</code>, and <code>std::tie</code> for unpack ing or multiple assignments is still not allowed. <a href="https://groups.google .com/a/chromium.org/d/topic/cxx/3DZ64dIMRTY/discussion">Discussion thread</a></t d> 401 <td>General use of <code>std::tuple</code>, and <code>std::tie</code> for unpack ing or multiple assignments is still not allowed. <a href="https://groups.google .com/a/chromium.org/d/topic/cxx/3DZ64dIMRTY/discussion">Discussion thread</a></t d>
382 </tr> 402 </tr>
383 403
384 <tr> 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-1bFBXM eUk">Discussion thread</a></td>
414 </tr>
415
416 <tr>
385 <td>Move Iterator Adaptor</td> 417 <td>Move Iterator Adaptor</td>
386 <td><code>std::make_move_iterator()</code></td> 418 <td><code>std::make_move_iterator()</code></td>
387 <td>Wraps an iterator so that it moves objects instead of copying them.</td> 419 <td>Wraps an iterator so that it moves objects instead of copying them.</td>
388 <td><a href="http://en.cppreference.com/w/cpp/iterator/make_move_iterator">std:: make_move_iterator</a></td> 420 <td><a href="http://en.cppreference.com/w/cpp/iterator/make_move_iterator">std:: make_move_iterator</a></td>
389 <td>Useful to move objects between containers that contain move-only types like <code>scoped_ptr</code>. <a href="https://groups.google.com/a/chromium.org/forum /#!topic/cxx/lccnUljOHQU">Discussion thread</a></td> 421 <td>Useful to move objects between containers that contain move-only types like <code>scoped_ptr</code>. <a href="https://groups.google.com/a/chromium.org/forum /#!topic/cxx/lccnUljOHQU">Discussion thread</a></td>
390 </tr> 422 </tr>
391 423
392 <tr> 424 <tr>
393 <td>Move Semantics</td> 425 <td>Move Semantics</td>
394 <td><code>std::move()</code></td> 426 <td><code>std::move()</code></td>
395 <td>Facilitates efficient move operations</td> 427 <td>Facilitates efficient move operations</td>
396 <td><a href="http://en.cppreference.com/w/cpp/utility/move"><code>std::move</cod e> reference</a></td> 428 <td><a href="http://en.cppreference.com/w/cpp/utility/move"><code>std::move</cod e> reference</a></td>
397 <td><a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/x_dWFxJF dbM'>Discussion thread</a></td> 429 <td><a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/x_dWFxJF dbM'>Discussion thread</a></td>
398 </tr> 430 </tr>
399 431
400 <tr> 432 <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 count erpart 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</c ode> reference</a></td>
405 <td>This is allowed, but there is almost always a way to write code without usin g 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
408 <tr>
409 <td>Type Traits</td> 433 <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 st orage (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_scala r</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>
411 <td>Allows compile-time inspection of the properties of types</td> 441 <td>Allows compile-time inspection of the properties of types</td>
412 <td><a href="http://en.cppreference.com/w/cpp/header/type_traits"> 442 <td><a href="http://en.cppreference.com/w/cpp/header/type_traits">&lt;type_trait s&gt;</a></td>
413 Standard library header &lt;type_traits&gt;</a></td>
414 <td>Note that not all type traits are available on all platforms (eg std::underl ying_type doesn't work in libstdc++4.6). Use judiciously. <a href='https://group s.google.com/a/chromium.org/forum/#!topic/cxx/vCxo4tZNd_M'>Discussion thread</a> </td> 443 <td>Note that not all type traits are available on all platforms (eg std::underl ying_type doesn't work in libstdc++4.6). Use judiciously. <a href='https://group s.google.com/a/chromium.org/forum/#!topic/cxx/vCxo4tZNd_M'>Discussion thread</a> </td>
415 </tr> 444 </tr>
416 445
417 <tr> 446 <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.g oogle.com/a/chromium.org/forum/#!topic/cxx/P-1bFBXMeUk">Discussion thread</a></t d>
423 </tr>
424
425 <tr>
426 <td>Unordered Associative Containers</td> 447 <td>Unordered Associative Containers</td>
427 <td><code>std::unordered_set</code>, <code>std::unordered_map</code>, 448 <td><code>std::unordered_set</code>, <code>std::unordered_map</code>,
428 <code>std::unordered_multiset</code>, and <code>std::unordered_multimap</code></ td> 449 <code>std::unordered_multiset</code>, and <code>std::unordered_multimap</code></ td>
429 <td>Allows efficient containers of key/value pairs</td> 450 <td>Allows efficient containers of key/value pairs</td>
430 <td><a href="http://en.cppreference.com/w/cpp/container/unordered_map">std::unor dered_map</a> 451 <td><a href="http://en.cppreference.com/w/cpp/container/unordered_map">std::unor dered_map</a>
431 and <a href="http://en.cppreference.com/w/cpp/container/unordered_set">std::unor dered_set</a> 452 and <a href="http://en.cppreference.com/w/cpp/container/unordered_set">std::unor dered_set</a>
432 </td> 453 </td>
433 <td>Per the <a href="https://google.github.io/styleguide/cppguide.html#std_hash" >Google style guide</a>, specify custom hashers instead of specializing <code>st d::hash</code> for custom types. <a href="https://groups.google.com/a/chromium.o rg/forum/#!topic/cxx/nCdjQqnouO4">Discussion thread</a>.</td> 454 <td>Per the <a href="https://google.github.io/styleguide/cppguide.html#std_hash" >Google style guide</a>, specify custom hashers instead of specializing <code>st d::hash</code> for custom types. <a href="https://groups.google.com/a/chromium.o rg/forum/#!topic/cxx/nCdjQqnouO4">Discussion thread</a>.</td>
434 </tr> 455 </tr>
435 456
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 <code>std::{un}declare_no_pointers()</code></td> 917 <code>std::{un}declare_no_pointers()</code></td>
897 <td>Enables garbage collection implementations</td> 918 <td>Enables garbage collection implementations</td>
898 <td><a href="http://en.cppreference.com/w/cpp/memory/gc/declare_reachable"> 919 <td><a href="http://en.cppreference.com/w/cpp/memory/gc/declare_reachable">
899 std::declare_reachable</a> 920 std::declare_reachable</a>
900 and <a href="http://en.cppreference.com/w/cpp/memory/gc/declare_no_pointers"> 921 and <a href="http://en.cppreference.com/w/cpp/memory/gc/declare_no_pointers">
901 std::declare_no_pointers</a></td> 922 std::declare_no_pointers</a></td>
902 <td></td> 923 <td></td>
903 </tr> 924 </tr>
904 925
905 <tr> 926 <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
913 <tr>
914 <td>Iterator Operators</td> 927 <td>Iterator Operators</td>
915 <td><code>std::next()</code> and <code>std::prev()</code></td> 928 <td><code>std::next()</code> and <code>std::prev()</code></td>
916 <td>Copies an iterator and increments or decrements the copy by 929 <td>Copies an iterator and increments or decrements the copy by
917 some value</td> 930 some value</td>
918 <td><a href="http://en.cppreference.com/w/cpp/iterator/next">std::next</a> 931 <td><a href="http://en.cppreference.com/w/cpp/iterator/next">std::next</a>
919 and <a href="http://en.cppreference.com/w/cpp/iterator/prev">std::prev</a> 932 and <a href="http://en.cppreference.com/w/cpp/iterator/prev">std::prev</a>
920 </td> 933 </td>
921 <td></td> 934 <td></td>
922 </tr> 935 </tr>
923 936
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 <td><a href="http://en.cppreference.com/w/cpp/string/basic_string/stol"> 1008 <td><a href="http://en.cppreference.com/w/cpp/string/basic_string/stol">
996 std::stoi, std::stol, std::stoll</a>, 1009 std::stoi, std::stol, std::stoll</a>,
997 <a href="http://en.cppreference.com/w/cpp/string/basic_string/stoul"> 1010 <a href="http://en.cppreference.com/w/cpp/string/basic_string/stoul">
998 std::stoul, std::stoull</a>, and 1011 std::stoul, std::stoull</a>, and
999 <a href="http://en.cppreference.com/w/cpp/string/basic_string/stof"> 1012 <a href="http://en.cppreference.com/w/cpp/string/basic_string/stof">
1000 std::stof, std::stod, std::stold</a> </td> 1013 std::stof, std::stod, std::stold</a> </td>
1001 <td></td> 1014 <td></td>
1002 </tr> 1015 </tr>
1003 1016
1004 <tr> 1017 <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
1013 <tr>
1014 <td>System Errors</td> 1018 <td>System Errors</td>
1015 <td><code>&lt;system_error&gt;</code></td> 1019 <td><code>&lt;system_error&gt;</code></td>
1016 <td>Provides a standard system error library</td> 1020 <td>Provides a standard system error library</td>
1017 <td><a href="http://en.cppreference.com/w/cpp/error/system_error">std::system_er ror</a></td> 1021 <td><a href="http://en.cppreference.com/w/cpp/error/system_error">std::system_er ror</a></td>
1018 <td></td> 1022 <td></td>
1019 </tr> 1023 </tr>
1020 1024
1021 <tr> 1025 <tr>
1022 <td>Trailing Return Types</td> 1026 <td>Trailing Return Types</td>
1023 <td><code>auto <i>function declaration</i> -> <i>return_type</i></code></td> 1027 <td><code>auto <i>function declaration</i> -> <i>return_type</i></code></td>
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 C++ Style Guide</a>. However, may be useful for 1113 C++ Style Guide</a>. However, may be useful for
1110 consuming non-ASCII data.</td> 1114 consuming non-ASCII data.</td>
1111 </tr> 1115 </tr>
1112 1116
1113 </tbody> 1117 </tbody>
1114 </table> 1118 </table>
1115 1119
1116 </div> 1120 </div>
1117 </body> 1121 </body>
1118 </html> 1122 </html>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698