Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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>Everything in <code><algorithm></code></td> | |
| 340 <td>Safe and performant implementations of common algorithms</td> | |
| 341 <td><a href="http://en.cppreference.com/w/cpp/header/algorithm"><code><algori thm></code></a></td> | |
| 342 <td>Note that range-based move() is allowed, but there is usually a way to write code without it that is cleaner and more readable. <a href="https://groups.goo gle.com/a/chromium.org/forum/#!topic/cxx/UJQk8S1IuHk">Discussion thread</a></td> | |
| 343 </tr> | |
| 344 | |
| 345 <tr> | |
| 338 <td>Begin and End Non-Member Functions</td> | 346 <td>Begin and End Non-Member Functions</td> |
| 339 <td><code>std::begin()</code> and <code>std::end()</code></td> | 347 <td><code>std::begin()</code> and <code>std::end()</code></td> |
| 340 <td>Allows use of free functions on any container, including | 348 <td>Allows use of free functions on any container, including |
| 341 fixed-size arrays</td> | 349 fixed-size arrays</td> |
| 342 <td><a href="http://en.cppreference.com/w/cpp/iterator/begin"> | 350 <td><a href="http://en.cppreference.com/w/cpp/iterator/begin"> |
| 343 std::begin</a> and | 351 std::begin</a> and |
| 344 <a href="http://en.cppreference.com/w/cpp/iterator/end"> | 352 <a href="http://en.cppreference.com/w/cpp/iterator/end"> |
| 345 std::end</a></td> | 353 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> | 354 <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> | 355 </tr> |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 375 | 383 |
| 376 <tr> | 384 <tr> |
| 377 <td>Lexicographical struct comparison</td> | 385 <td>Lexicographical struct comparison</td> |
| 378 <td><code>tie(a, b, c) <<br> tie(rhs.a, rhs.b, rhs.c)</code></td> | 386 <td><code>tie(a, b, c) <<br> tie(rhs.a, rhs.b, rhs.c)</code></td> |
| 379 <td>Idiom for <code>operator<</code> implementation</td> | 387 <td>Idiom for <code>operator<</code> implementation</td> |
| 380 <td><a href="http://en.cppreference.com/w/cpp/utility/tuple/tie">std::tie</a></t d> | 388 <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> | 389 <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> | 390 </tr> |
| 383 | 391 |
| 384 <tr> | 392 <tr> |
| 393 <td>Math functions</td> | |
| 394 <td>Everything in <code><cmath></code></td> | |
| 395 <td>Useful for math-related code</td> | |
| 396 <td><a href="http://en.cppreference.com/w/cpp/header/cmath"><code><cmath>< /code></a></td> | |
| 397 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/P-1bFBXM eUk">Discussion thread</a></td> | |
| 398 </tr> | |
| 399 | |
| 400 <tr> | |
| 385 <td>Move Iterator Adaptor</td> | 401 <td>Move Iterator Adaptor</td> |
| 386 <td><code>std::make_move_iterator()</code></td> | 402 <td><code>std::make_move_iterator()</code></td> |
| 387 <td>Wraps an iterator so that it moves objects instead of copying them.</td> | 403 <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> | 404 <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> | 405 <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> | 406 </tr> |
| 391 | 407 |
| 392 <tr> | 408 <tr> |
| 393 <td>Move Semantics</td> | 409 <td>Move Semantics</td> |
| 394 <td><code>std::move()</code></td> | 410 <td><code>std::move()</code></td> |
| 395 <td>Facilitates efficient move operations</td> | 411 <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> | 412 <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> | 413 <td><a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/x_dWFxJF dbM'>Discussion thread</a></td> |
| 398 </tr> | 414 </tr> |
| 399 | 415 |
| 400 <tr> | 416 <tr> |
| 401 <td>Range Move</td> | |
| 402 <td><code>std::move()</code></td> | |
|
danakj
2016/02/03 23:32:19
Can you keep this as a separate point, or keep the
Nico
2016/02/03 23:46:09
you mean the "Moves contents of an iterator range
danakj
2016/02/03 23:47:51
I was thinking also of the "probably don't use tho
Peter Kasting
2016/02/03 23:54:09
So, are you saying the wording for that that I kep
| |
| 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> | 417 <td>Type Traits</td> |
| 410 <td>Class templates within <code><type_traits></code></td> | 418 <td>Everything in <code><type_traits></code></td> |
| 411 <td>Allows compile-time inspection of the properties of types</td> | 419 <td>Allows compile-time inspection of the properties of types</td> |
| 412 <td><a href="http://en.cppreference.com/w/cpp/header/type_traits"> | 420 <td><a href="http://en.cppreference.com/w/cpp/header/type_traits"><type_trait s></a></td> |
| 413 Standard library header <type_traits></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> | 421 <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> | 422 </tr> |
| 416 | 423 |
| 417 <tr> | 424 <tr> |
| 418 <td>Types, functions, and constants from <code><cmath></code></td> | |
| 419 <td><code>std::round()</code>, <code>std::isnan()</code>, and others</td> | |
|
Nico
2016/02/03 23:46:09
i like having these function snippets; i ctrl-f fo
Peter Kasting
2016/02/03 23:54:09
I don't like picking a couple of functions seeming
| |
| 420 <td>Useful for math-related code</td> | |
| 421 <td><a href="http://en.cppreference.com/w/cpp/header/cmath"><code><cmath>< /code></a></td> | |
| 422 <td>Anything in <code><cmath></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> | 425 <td>Unordered Associative Containers</td> |
| 427 <td><code>std::unordered_set</code>, <code>std::unordered_map</code>, | 426 <td><code>std::unordered_set</code>, <code>std::unordered_map</code>, |
| 428 <code>std::unordered_multiset</code>, and <code>std::unordered_multimap</code></ td> | 427 <code>std::unordered_multiset</code>, and <code>std::unordered_multimap</code></ td> |
| 429 <td>Allows efficient containers of key/value pairs</td> | 428 <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> | 429 <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> | 430 and <a href="http://en.cppreference.com/w/cpp/container/unordered_set">std::unor dered_set</a> |
| 432 </td> | 431 </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> | 432 <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> | 433 </tr> |
| 435 | 434 |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 896 <code>std::{un}declare_no_pointers()</code></td> | 895 <code>std::{un}declare_no_pointers()</code></td> |
| 897 <td>Enables garbage collection implementations</td> | 896 <td>Enables garbage collection implementations</td> |
| 898 <td><a href="http://en.cppreference.com/w/cpp/memory/gc/declare_reachable"> | 897 <td><a href="http://en.cppreference.com/w/cpp/memory/gc/declare_reachable"> |
| 899 std::declare_reachable</a> | 898 std::declare_reachable</a> |
| 900 and <a href="http://en.cppreference.com/w/cpp/memory/gc/declare_no_pointers"> | 899 and <a href="http://en.cppreference.com/w/cpp/memory/gc/declare_no_pointers"> |
| 901 std::declare_no_pointers</a></td> | 900 std::declare_no_pointers</a></td> |
| 902 <td></td> | 901 <td></td> |
| 903 </tr> | 902 </tr> |
| 904 | 903 |
| 905 <tr> | 904 <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> | 905 <td>Iterator Operators</td> |
| 915 <td><code>std::next()</code> and <code>std::prev()</code></td> | 906 <td><code>std::next()</code> and <code>std::prev()</code></td> |
| 916 <td>Copies an iterator and increments or decrements the copy by | 907 <td>Copies an iterator and increments or decrements the copy by |
| 917 some value</td> | 908 some value</td> |
| 918 <td><a href="http://en.cppreference.com/w/cpp/iterator/next">std::next</a> | 909 <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> | 910 and <a href="http://en.cppreference.com/w/cpp/iterator/prev">std::prev</a> |
| 920 </td> | 911 </td> |
| 921 <td></td> | 912 <td></td> |
| 922 </tr> | 913 </tr> |
| 923 | 914 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 995 <td><a href="http://en.cppreference.com/w/cpp/string/basic_string/stol"> | 986 <td><a href="http://en.cppreference.com/w/cpp/string/basic_string/stol"> |
| 996 std::stoi, std::stol, std::stoll</a>, | 987 std::stoi, std::stol, std::stoll</a>, |
| 997 <a href="http://en.cppreference.com/w/cpp/string/basic_string/stoul"> | 988 <a href="http://en.cppreference.com/w/cpp/string/basic_string/stoul"> |
| 998 std::stoul, std::stoull</a>, and | 989 std::stoul, std::stoull</a>, and |
| 999 <a href="http://en.cppreference.com/w/cpp/string/basic_string/stof"> | 990 <a href="http://en.cppreference.com/w/cpp/string/basic_string/stof"> |
| 1000 std::stof, std::stod, std::stold</a> </td> | 991 std::stof, std::stod, std::stold</a> </td> |
| 1001 <td></td> | 992 <td></td> |
| 1002 </tr> | 993 </tr> |
| 1003 | 994 |
| 1004 <tr> | 995 <tr> |
| 1005 <td>STL Algorithms</td> | |
| 1006 <td>Functions within <code><algorithm></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> | 996 <td>System Errors</td> |
| 1015 <td><code><system_error></code></td> | 997 <td><code><system_error></code></td> |
| 1016 <td>Provides a standard system error library</td> | 998 <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> | 999 <td><a href="http://en.cppreference.com/w/cpp/error/system_error">std::system_er ror</a></td> |
| 1018 <td></td> | 1000 <td></td> |
| 1019 </tr> | 1001 </tr> |
| 1020 | 1002 |
| 1021 <tr> | 1003 <tr> |
| 1022 <td>Trailing Return Types</td> | 1004 <td>Trailing Return Types</td> |
| 1023 <td><code>auto <i>function declaration</i> -> <i>return_type</i></code></td> | 1005 <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 Loading... | |
| 1109 C++ Style Guide</a>. However, may be useful for | 1091 C++ Style Guide</a>. However, may be useful for |
| 1110 consuming non-ASCII data.</td> | 1092 consuming non-ASCII data.</td> |
| 1111 </tr> | 1093 </tr> |
| 1112 | 1094 |
| 1113 </tbody> | 1095 </tbody> |
| 1114 </table> | 1096 </table> |
| 1115 | 1097 |
| 1116 </div> | 1098 </div> |
| 1117 </body> | 1099 </body> |
| 1118 </html> | 1100 </html> |
| OLD | NEW |