| <!DOCTYPE html> |
| <!-- |
| Copyright 2014 The Chromium Authors. All rights reserved. |
| Use of this source code is governed by a BSD-style license that can be |
| found in the LICENSE file. |
| --> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <title>Modern C++ use in Chromium</title> |
| <link rel="stylesheet" href="c++11.css"> |
| <style> |
| table tbody tr td:first-child { |
| font-weight: bold; |
| font-size: 110%; |
| } |
| </style> |
| </head> |
| <body> |
| <div id="content"> |
| <h1>Modern C++ use in Chromium</h1> |
| |
| <p><i>This document lives at |
| <a href="https://source.chromium.org/chromium/chromium/src/+/main:styleguide/c++/c++11.html"> |
| src/styleguide/c++/c++11.html</a> in a Chromium checkout and is part of the more general |
| <a href="https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++.md"> |
| Chromium C++ style guide</a>. It summarizes the supported state of new and |
| updated language and library features in recent C++ standards and the |
| <a href="https://abseil.io/about/">Abseil</a> library. This guide |
| applies to both Chromium and its subprojects, though subprojects can choose to |
| be more restrictive if necessary for toolchain support.</i></p> |
| |
| <p>The C++ language has in recent years received an updated standard every three |
| years (C++11, C++14, C++17). For various reasons, Chromium does not immediately |
| allow new features on the publication of such a standard. Instead, once |
| toolchain support is sufficient, a standard is declared "initially supported", |
| with new language/library features banned pending discussion.</p> |
| |
| <p>You can propose changing the status of a feature by sending an email to |
| <a href="https://groups.google.com/a/chromium.org/forum/#!forum/cxx"> |
| cxx@chromium.org</a>. Include a short blurb on what the feature is and why you |
| think it should or should not be allowed, along with links to any relevant |
| previous discussion. If the list arrives at some consensus, send a codereview to |
| change this file accordingly, linking to your discussion thread.</p> |
| |
| <p>If an item remains on the TBD list two years after initial support is added, |
| style arbiters should explicitly move it to an appropriate allowlist or blocklist, |
| allowing it if there are no obvious reasons to ban. |
| The current status of existing standards and Abseil features is: |
| |
| <ul><li><b>C++11:</b> <i>Default allowed; see banned features below</i></li> |
| <li><b>C++14:</b> <i>Default allowed; see banned features below</i></li> |
| <li><b>C++17:</b> <i>Not yet supported in Chromium, unlikely before mid-2021; <a href="http://crbug.com/752720">tracking bug</a></i></li> |
| <li><b>C++20:</b> <i>Not yet standardized</i></li> |
| <li><b>Abseil:</b> Initially supported July 31, 2020; see allowed/banned/TBD features below |
| <ul> |
| <li>absl::StatusOr: Initially supported September 3, 2020</li> |
| <li>absl::Cleanup: Initially supported February 4, 2021</li> |
| </ul></li> |
| </ul></p> |
| |
| |
| <h2>Table of Contents</h2> |
| <ol class="toc"> |
| <li>Allowed Features<ol> |
| <li>Library |
| <a href="#absl-allowlist">Abseil</a> |
| </li> |
| </ol></li> |
| <li>Banned Features<ol> |
| <li>Language |
| <a href="#core-blocklist">C++11</a> |
| </li> |
| <li>Library |
| <a href="#library-blocklist">C++11</a> |
| <a href="#library-blocklist-14">C++14</a> |
| <a href="#absl-blocklist">Abseil</a> |
| </li> |
| </ol></li> |
| <li>To Be Discussed<ol> |
| <li>Library |
| <a href="#absl-review">Abseil</a> |
| </li> |
| </ol></li> |
| </li> |
| </ol> |
| |
| <h2 id="blocklist_banned"><a name="core-blocklist"></a>C++11 Banned Language Features</h2> |
| |
| <p>The following C++11 language features are not allowed in the Chromium codebase.</p> |
| |
| <table id="banned_list" class="unlined striped"> |
| <tbody> |
| |
| <tr> |
| <th style='width:240px;'>Feature or Library</th> |
| <th style='width:240px;'>Snippet</th> |
| <th style='width:240px;'>Description</th> |
| <th style='width:240px;'>Documentation Link</th> |
| <th style='width:240px;'>Notes and Discussion Thread</th> |
| </tr> |
| |
| <tr> |
| <td>Inline Namespaces</td> |
| <td><code>inline namespace foo { ... }</code></td> |
| <td>Allows better versioning of namespaces</td> |
| <td><a href="http://en.cppreference.com/w/cpp/language/namespace#Inline_namespaces">Inline namespaces</a></td> |
| <td>Banned in the <a href="https://google.github.io/styleguide/cppguide.html#Namespaces">Google Style Guide</a>. Unclear how it will work with components.</td> |
| </tr> |
| |
| <tr> |
| <td><code>long long</code> Type</td> |
| <td><code>long long <i>var</i> = <i>value</i>;</code></td> |
| <td>An integer of at least 64 bits</td> |
| <td><a href="http://en.cppreference.com/w/cpp/language/types">Fundamental types</a></td> |
| <td>Use a stdint.h type if you need a 64-bit number. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/RxugZ-pIDxk">Discussion thread</a></td> |
| </tr> |
| |
| <tr> |
| <td>User-Defined Literals</td> |
| <td><code><i>type</i> <i>var</i> = <i>literal_value</i>_<i>type</i></code></td> |
| <td>Allows user-defined literal expressions</td> |
| <td><a href="http://en.cppreference.com/w/cpp/language/user_literal">User-defined literals</a></td> |
| <td>Banned in the <a href="https://google.github.io/styleguide/cppguide.html#Operator_Overloading">Google Style Guide</a>.</td> |
| </tr> |
| |
| <tr> |
| <td>thread_local storage class</td> |
| <td><code>thread_local int foo = 1;</code></td> |
| <td>Puts variables into thread local storage.</td> |
| <td><a href="http://en.cppreference.com/w/cpp/language/storage_duration">Storage duration</a></td> |
| <td>Some surprising effects on Mac (<a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/2msN8k3Xzgs">discussion</a>, <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/h7O5BdtWCZw">fork</a>). Use <code>base::SequenceLocalStorageSlot</code> for sequence support, and <code>base::ThreadLocal</code>/<code>base::ThreadLocalStorage</code> otherwise.</td> |
| </tr> |
| |
| </tbody> |
| </table> |
| |
| <h2 id="blocklist_stdlib"><a name="library-blocklist"></a>C++11 Banned Library Features</h2> |
| |
| <p>The following C++11 library features are not allowed in the Chromium codebase.</p> |
| |
| <table id="blocklist_lib_list" class="unlined striped"> |
| <tbody> |
| |
| <tr> |
| <th style='width:240px;'>Feature</th> |
| <th style='width:240px;'>Snippet</th> |
| <th style='width:240px;'>Description</th> |
| <th style='width:240px;'>Documentation Link</th> |
| <th style='width:240px;'>Notes and Discussion Thread</th> |
| </tr> |
| |
| <td>Bind Operations</td> |
| <td><code>std::bind(<i>function</i>, <i>args</i>, ...)</code></td> |
| <td>Declares a function object bound to certain arguments</td> |
| <td><a href="http://en.cppreference.com/w/cpp/utility/functional/bind">std::bind</a></td> |
| <td>Use <code>base::Bind</code> instead. Compared to <code>std::bind</code>, <code>base::Bind</code> helps prevent lifetime issues by preventing binding of capturing lambdas and by forcing callers to declare raw pointers as <code>Unretained</code>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/SoEj7oIDNuA">Discussion thread</a></td> |
| </tr> |
| |
| <tr> |
| <td>C Floating-Point Environment</td> |
| <td><code><cfenv></code>, <code><fenv.h></code></td> |
| <td>Provides floating point status flags and control modes for C-compatible code</td> |
| <td><a href="http://en.cppreference.com/w/cpp/header/cfenv">Standard library header <cfenv></a></td> |
| <td>Banned by the <a href="https://google.github.io/styleguide/cppguide.html#C++11">Google Style Guide</a> due to concerns about compiler support.</td> |
| </tr> |
| |
| <tr> |
| <td>Date and time utilities</td> |
| <td><code><chrono></code></td> |
| <td>A standard date and time library</td> |
| <td><a href="http://en.cppreference.com/w/cpp/chrono">Date and time utilities</a></td> |
| <td>Overlaps with <code>Time</code> APIs in <code>base/</code>. Keep using the <code>base/</code> classes.</td> |
| </tr> |
| |
| <tr> |
| <td>Exceptions</td> |
| <td><code><exception></code></td> |
| <td>Enhancements to exception throwing and handling</td> |
| <td><a href="http://en.cppreference.com/w/cpp/header/exception">Standard library header <exception></a></td> |
| <td>Exceptions are banned by the <a href="https://google.github.io/styleguide/cppguide.html#Exceptions">Google Style Guide</a> and disabled in Chromium compiles. However, the <code>noexcept</code> specifier is explicitly allowed. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/8i4tMqNpHhg">Discussion thread</a></td> |
| </tr> |
| |
| <tr> |
| <td>Function Objects</td> |
| <td><code>std::function</code></td> |
| <td>Wraps a standard polymorphic function</td> |
| <td><a href="http://en.cppreference.com/w/cpp/utility/functional/function">std::function</a></td> |
| <td>Use <code>base::{Once,Repeating}Callback</code> instead. Compared to <code>std::function</code>, <code>base::{Once,Repeating}Callback</code> directly supports Chromium's refcounting classes and weak pointers and deals with additional thread safety concerns. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/SoEj7oIDNuA">Discussion thread</a></td> |
| </tr> |
| |
| <tr> |
| <td>Random Number Engines</td> |
| <td>The random number engines defined in <code><random></code> (see separate item for random number distributions), e.g.:<br/> |
| <code>linear_congruential_engine</code>, <code>mersenne_twister_engine</code><br/> |
| <code>minstd_rand0</code>, <code>mt19937</code>, <code>ranlinux48</code><br/> |
| <code>random_device</code> |
| </td> |
| <td>Random number generation algorithms and utilities.</td> |
| <td><a href="http://en.cppreference.com/w/cpp/numeric/random">Pseudo-random number generation</a></td> |
| <td>Do not use any random number engines from <code><random></code>. Instead, use <code>base::RandomBitGenerator</code>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/16Xmw05C-Y0">Discussion thread</a></td> |
| </tr> |
| |
| <tr> |
| <td>Ratio Template Class</td> |
| <td><code>std::ratio<<i>numerator</i>, <i>denominator</i>></code></td> |
| <td>Provides compile-time rational numbers</td> |
| <td><a href="http://en.cppreference.com/w/cpp/numeric/ratio/ratio">std::ratio</a></td> |
| <td>Banned by the <a href="https://google.github.io/styleguide/cppguide.html#C++11">Google Style Guide</a> due to concerns that this is tied to a more template-heavy interface style.</td> |
| </tr> |
| |
| <tr> |
| <td>Regular Expressions</td> |
| <td><code><regex></code></td> |
| <td>A standard regular expressions library</td> |
| <td><a href="http://en.cppreference.com/w/cpp/regex">Regular expressions library</a></td> |
| <td>Overlaps with many regular expression libraries in Chromium. When in doubt, use re2.</td> |
| </tr> |
| |
| <tr> |
| <td>Shared Pointers</td> |
| <td><code>std::shared_ptr</code></td> |
| <td>Allows shared ownership of a pointer through reference counts</td> |
| <td><a href="http://en.cppreference.com/w/cpp/memory/shared_ptr">std::shared_ptr</a></td> |
| <td>Needs a lot more evaluation for Chromium, and there isn't enough of a push for this feature. <a href="https://google.github.io/styleguide/cppguide.html#Ownership_and_Smart_Pointers">Google Style Guide</a>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/aT2wsBLKvzI">Discussion Thread</a></td> |
| </tr> |
| |
| <tr> |
| <td>String-Number Conversion Functions</td> |
| <td><code>std::stoi()</code>, <code>std::stol()</code>, <code>std::stoul()</code>, <code>std::stoll</code>, <code>std::stoull()</code>, <code>std::stof()</code>, <code>std::stod()</code>, <code>std::stold()</code>, <code>std::to_string()</code></td> |
| <td>Converts strings to/from numbers</td> |
| <td><a href="http://en.cppreference.com/w/cpp/string/basic_string/stol">std::stoi, std::stol, std::stoll</a>, <a href="http://en.cppreference.com/w/cpp/string/basic_string/stoul">std::stoul, std::stoull</a>, <a href="http://en.cppreference.com/w/cpp/string/basic_string/stof">std::stof, std::stod, std::stold</a>, <a href="http://en.cppreference.com/w/cpp/string/basic_string/to_string">std::to_string</a></td> |
| <td>The string-to-number conversions rely on exceptions to communicate failure, while the number-to-string conversions have performance concerns and depend on the locale. Use the routines in <code>base/strings/string_number_conversions.h</code> instead.</td> |
| </tr> |
| |
| <tr> |
| <td>Thread Library</td> |
| <td><code><thread></code> and related headers, including<br /> |
| <code><future></code>, <code><mutex></code>, <code><condition_variable></code></td> |
| <td>Provides a standard multithreading library using <code>std::thread</code> and associates</td> |
| <td><a href="http://en.cppreference.com/w/cpp/thread">Thread support library</a></td> |
| <td>Overlaps with many classes in <code>base/</code>. Keep using the <code>base/</code> classes for now. <code>base::Thread</code> is tightly coupled to <code>MessageLoop</code> which would make it hard to replace. We should investigate using standard mutexes, or unique_lock, etc. to replace our locking/synchronization classes.</td> |
| </tr> |
| |
| <tr> |
| <td>Weak Pointers</td> |
| <td><code>std::weak_ptr</code></td> |
| <td>Allows a weak reference to a <code>std::shared_ptr</code></td> |
| <td><a href="http://en.cppreference.com/w/cpp/memory/weak_ptr">std::weak_ptr</a></td> |
| <td>Banned because <code>std::shared_ptr</code> is banned. Use <code>base::WeakPtr</code> instead.</td> |
| </tr> |
| |
| </tbody> |
| </table> |
| |
| <h2 id="blocklist_stdlib"><a name="library-blocklist-14"></a>C++14 Banned Library Features</h2> |
| |
| <p>The following C++14 library features are not allowed in the Chromium codebase.</p> |
| |
| <table id="blocklist_lib_list" class="unlined striped"> |
| <tbody> |
| |
| <tr> |
| <th style='width:240px;'>Feature</th> |
| <th style='width:240px;'>Snippet</th> |
| <th style='width:240px;'>Description</th> |
| <th style='width:240px;'>Documentation Link</th> |
| <th style='width:240px;'>Notes and Discussion Thread</th> |
| </tr> |
| |
| <tr> |
| <td><code>std::chrono</code> literals</td> |
| <td><code>using namespace std::chrono_literals;<br>auto timeout = 30s;</code></td> |
| <td>Allows <code>std::chrono</code> types to be more easily constructed.</td> |
| <td><a href="http://en.cppreference.com/w/cpp/chrono/operator%22%22s">std::literals::chrono_literals::operator""s</a></td> |
| <td>Banned because <code><chrono></code> is banned.</td> |
| </tr> |
| |
| </tbody> |
| </table> |
| |
| <h2 id="allowlist_abseil"><a name="absl-allowlist"></a>Abseil Allowed Library Features</h2> |
| |
| <p>The following Abseil library features are allowed in the Chromium codebase.</p> |
| |
| <table id="allowlist_abseil_list" class="unlined striped"> |
| <tbody> |
| |
| <tr> |
| <th style='width:240px;'>Feature</th> |
| <th style='width:240px;'>Snippet</th> |
| <th style='width:240px;'>Description</th> |
| <th style='width:240px;'>Documentation Link</th> |
| <th style='width:240px;'>Notes and Discussion Thread</th> |
| </tr> |
| |
| <tr> |
| <td>Optional</td> |
| <td><code>absl::optional</code></td> |
| <td>Early adaptation of C++17 std::optional.</td> |
| <td><a href="https://en.cppreference.com/w/cpp/utility/optional">std::optional</a></td> |
| <td>Replaces <code>base::Optional</code>. <a href="https://groups.google.com/a/chromium.org/g/cxx/c/zUGqagX1NFU">Discussion thread</a></td> |
| </tr> |
| |
| <tr> |
| <td>Status</td> |
| <td><code>absl::Status</code></td> |
| <td>Type for returning detailed errors.</td> |
| <td><a href="https://source.chromium.org/chromium/chromium/src/+/main:third_party/abseil-cpp/absl/status/status.h">status.h</a></td> |
| <td>Approved for use inside a wrapper type. Use <a href="https://source.chromium.org/chromium/chromium/src/+/main:base/strings/abseil_string_conversions.h">abseil_string_conversions.h</a> to convert to and from <a href="https://source.chromium.org/chromium/chromium/src/+/main:third_party/abseil-cpp/absl/strings/string_view.h">absl::string_view</a> so the wrapper can expose <a href="https://source.chromium.org/chromium/chromium/src/+/main:base/strings/string_piece.h">base::StringPiece</a>. Use <a href="https://source.chromium.org/chromium/chromium/src/+/main:third_party/abseil-cpp/absl/strings/cord.h">absl::Cord</a> directly as minimally necessary to interface; do not expose in the wrapper type API.<br> |
| <a href="https://groups.google.com/a/chromium.org/g/cxx/c/ImdFCSZ-NMA">Discussion thread</a></td> |
| </tr> |
| |
| <tr> |
| <td>Variant</td> |
| <td><code>absl::variant</code></td> |
| <td>Early adaptation of C++17 std::variant.</td> |
| <td><a href="https://en.cppreference.com/w/cpp/utility/variant">std::variant</a></td> |
| <td><a href="https://groups.google.com/a/chromium.org/g/cxx/c/DqvG-TpvMyU">Discussion thread</a></td> |
| </tr> |
| |
| </tbody> |
| </table> |
| |
| <h2 id="blocklist_absl"><a name="absl-blocklist"></a>Abseil Banned Library Features</h2> |
| |
| <p>The following Abseil library features are not allowed in the Chromium codebase.</p> |
| |
| <table id="blocklist_absl_list" class="unlined striped"> |
| <tbody> |
| |
| <tr> |
| <th style='width:240px;'>Feature</th> |
| <th style='width:240px;'>Snippet</th> |
| <th style='width:240px;'>Description</th> |
| <th style='width:240px;'>Documentation Link</th> |
| <th style='width:240px;'>Notes and Discussion Thread</th> |
| </tr> |
| |
| <tr> |
| <td>Any</td> |
| <td><code>absl::any a = int{5}; |
| <br>EXPECT_THAT(absl::any_cast<int>(&a), Pointee(5)); |
| <br>EXPECT_EQ(absl::any_cast<size_t>(&a), nullptr);</code></td> |
| <td>Early adaptation of C++17 std::any.</td> |
| <td><a href="https://en.cppreference.com/w/cpp/utility/any">std::any</a></td> |
| <td>Banned since workaround for lack of RTTI isn't compatible with the component build. <a href="http://crbug.com/1096380">Bug</a></td> |
| </tr> |
| |
| <tr> |
| <td>Command line flags</td> |
| <td><code>ABSL_FLAG(bool, logs, false, "print logs to stderr");<br>app --logs=true;</code></td> |
| <td>Allows programmatic access to flag values passed on the command-line to binaries.</td> |
| <td><a href="https://abseil.io/docs/cpp/guides/flags">Flags Library</a></td> |
| <td>Banned since workaround for lack of RTTI isn't compatible with the component build. <a href="http://crbug.com/1096380">Bug</a><br> |
| Use <code>base::CommandLine</code> instead.</td> |
| </tr> |
| |
| <tr> |
| <td>Span</td> |
| <td><code>absl::Span</code></td> |
| <td>Early adaptation of C++20 std::span.</td> |
| <td><a href="https://abseil.io/tips/93">Using absl::Span</a></td> |
| <td>Banned due to being less std::-compliant than <code>base::span</code>. |
| <br>Keep using <code>base::span</code>.</td> |
| </tr> |
| |
| <tr> |
| <td>string_view</td> |
| <td><code>absl::string_view</code></td> |
| <td>Early adaptation of C++17 std::string_view.</td> |
| <td><a href="https://abseil.io/tips/1">absl::string_view</a></td> |
| <td>Banned due to only working with 8-bit characters. |
| Keep using <code>base::StringPiece</code> from <code>base/strings/</code>.</td> |
| </tr> |
| |
| </tbody> |
| </table> |
| |
| <h2 id="review_abseil"><a name="absl-review"></a>Abseil TBD Features</h2> |
| |
| <p>The following Abseil library features are not allowed in the Chromium codebase. |
| See the top of this page on how to propose moving a feature from this list into |
| the allowed or banned sections.</p> |
| |
| <table id="absl_review_list" class="unlined striped"> |
| <tbody> |
| |
| <tr> |
| <th style='width:240px;'>Feature</th> |
| <th style='width:240px;'>Snippet</th> |
| <th style='width:240px;'>Description</th> |
| <th style='width:240px;'>Documentation Link</th> |
| <th style='width:240px;'>Notes and Discussion Thread</th> |
| </tr> |
| |
| <tr> |
| <td>128bit integer</td> |
| <td><code>uint64_t a;<br>absl::uint128 v = a;</code></td> |
| <td>Signed and unsigned 128-bit integer types meant to mimic intrinsic types as closely as possible.</td> |
| <td><a href="https://abseil.io/docs/cpp/guides/numeric">Numerics</a></td> |
| <td></td> |
| </tr> |
| |
| <tr> |
| <td>bind_front</td> |
| <td><code>absl::bind_front</code></td> |
| <td>Binds the first N arguments of an invocable object and stores them by value.</td> |
| <td><a href="https://source.chromium.org/chromium/chromium/src/+/main:third_party/abseil-cpp/absl/functional/bind_front.h">bind_front.h</a> |
| <br><a href="https://abseil.io/tips/108">Avoid std::bind</a></td> |
| <td>Overlaps with <code>base::Bind</code>.</td> |
| </tr> |
| |
| <tr> |
| <td>Cleanup</td> |
| <td><code>FILE* sink_file = fopen(sink_path, "w");<br>auto sink_closer = absl::MakeCleanup([sink_file] { fclose(sink_file); });</code></td> |
| <td>Implements the scope guard idiom, invoking the contained callback's `operator()() &&` on scope exit.</td> |
| <td><a href="https://source.chromium.org/chromium/chromium/src/+/main:third_party/abseil-cpp/absl/cleanup/cleanup.h">cleanup.h</a></td> |
| <td>Similar to `defer` in Golang.</td> |
| </tr> |
| |
| <tr> |
| <td>Containers</td> |
| <td><code>absl::flat_hash_map, absl::flat_hash_set,<br>absl::node_hash_map, absl::node_hash_set,<br> |
| absl::btree_map, absl::btree_set,<br>absl::btree_multimap, absl::btree_multiset,<br> |
| absl::InlinedVector, absl::FixedArray</code></td> |
| <td>Alternatives to STL containers designed to be more efficient in the general case.</td> |
| <td><a href="https://abseil.io/docs/cpp/guides/container">Containers</a><br> |
| <a href="https://abseil.io/docs/cpp/guides/hash">Hash</a></td> |
| <td>Supplements <code>base/containers/</code>.</td> |
| </tr> |
| |
| <tr> |
| <td>Container utilities</td> |
| <td><code>auto it = absl::c_find(container, value);</code></td> |
| <td>Container-based versions of algorithmic functions within C++ standard library.</td> |
| <td><a href="https://source.chromium.org/chromium/chromium/src/+/main:third_party/abseil-cpp/absl/algorithm/container.h">container.h</a></td> |
| <td>Overlaps with <code>base/ranges/algorithm.h</code>.</td> |
| </tr> |
| |
| <tr> |
| <td>FunctionRef</td> |
| <td><code>absl::FunctionRef</code></td> |
| <td>Type for holding a non-owning reference to an object of any invocable type.</td> |
| <td><a href="https://source.chromium.org/chromium/chromium/src/+/main:third_party/abseil-cpp/absl/functional/function_ref.h">function_ref.h</a></td> |
| <td></td> |
| </tr> |
| |
| <tr> |
| <td>Random</td> |
| <td><code>absl::BitGen bitgen;<br> |
| size_t index = absl::Uniform(bitgen, 0u, elems.size());</code></td> |
| <td>Functions and utilities for generating pseudorandom data.</td> |
| <td><a href="https://abseil.io/docs/cpp/guides/random">Random library</a></td> |
| <td>Overlaps with <code>base/rand_util.h</code>.</td> |
| </tr> |
| |
| <tr> |
| <td>StatusOr</td> |
| <td><code>absl::StatusOr<T></td> |
| <td>An object that is either a usable value, or an error Status explaining why such a value is not present.</td> |
| <td><a href="https://source.chromium.org/chromium/chromium/src/+/main:third_party/abseil-cpp/absl/status/statusor.h">statusor.h</a></td> |
| <td></td> |
| </tr> |
| |
| <tr> |
| <td>String Formatting</td> |
| <td><code>absl::StrFormat</code> |
| <td>A typesafe replacement for the family of printf() string formatting routines.</td> |
| <td><a href="https://abseil.io/docs/cpp/guides/format">String Formatting</a> |
| <td></td> |
| </tr> |
| |
| <tr> |
| <td>Strings Library</td> |
| <td><code>absl::StrSplit, absl::StrJoin,<br> absl::StrCat, absl::StrAppend,<br> absl::Substitute, absl::StrContains</code></td> |
| <td>Classes and utility functions for manipulating and comparing strings.</td> |
| <td><a href="https://abseil.io/docs/cpp/guides/strings">String Utilities</a> |
| <td>Overlaps with <code>base/strings</code>.</td> |
| </tr> |
| |
| <tr> |
| <td>Synchronization</td> |
| <td><code>absl::Mutex</code></td> |
| <td>Primitives for managing tasks across different threads.</td> |
| <td><a href="https://abseil.io/docs/cpp/guides/synchronization">Synchronization</a></td> |
| <td>Overlaps with <code>Lock</code> in <code>base/synchronization/</code>.</td> |
| </tr> |
| |
| <tr> |
| <td>Time library</td> |
| <td><code>absl::Duration, absl::Time,<br> absl::TimeZone, absl::CivilDay</code></td> |
| <td>Abstractions for holding time values, both in terms of absolute time and civil time.</td> |
| <td><a href="https://abseil.io/docs/cpp/guides/time">Time</a></td> |
| <td>Overlaps with <code>Time</code> APIs in <code>base/</code>.</td> |
| </tr> |
| |
| </tbody> |
| </table> |
| |
| </div> |
| </body> |
| </html> |