In this document, the phrase
Clauses and subclauses in this document are annotated with a so-called stable name, presented in square brackets next to the (sub)clause heading (such as "[introduction]" for this clause). Stable names aid in the discussion and evolution of this document by serving as stable references to subclauses across editions that are unaffected by changes of subclause numbering.
This document describes extensions to the C++
Standard Library (
Some of the library components in this document might be considered for standardization in a future version of C++, but they are not currently part of any C++ standard. Some of the components in this document might never be standardized, and others might be standardized in a substantially changed form.
The goal of this document is to build more widespread existing practice for an expanded C++ standard library. It gives advice on extensions to those vendors who wish to provide them.
The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.
For the purposes of this document, the terms and definitions given in ISO/IEC 14882:2020 apply.
ISO and IEC maintain terminology databases for use in standardization at the following addresses:
Since the extensions described in this document
are experimental and not part of the C++ standard library, they
should not be declared directly within namespace
std.
Unless otherwise specified, all components described in this document either:
::experimental::fundamentals_v3
to a namespace defined in the C++ Standard Library,
such as std or std::chrono, or
std.
std::experimental::fundamentals_v3::pmr
because the C++ Standard Library defines std::pmr.
Each header described in this document shall import the contents of
std::experimental::fundamentals_v3 into
std::experimental as if by
namespace std::experimental::inline fundamentals_v3 {}
This document also describes some experimental modifications to existing interfaces in the C++ Standard Library.
Unless otherwise specified, references to other entities
described in this document are assumed to be
qualified with std::experimental::fundamentals_v3::,
and references to entities described in the standard are assumed
to be qualified with std::.
Extensions that are expected to eventually be added to an
existing header <meow> are provided inside the
<experimental/meow> header, which shall include
the standard contents of <meow> as if by
#include <meow>
New headers are also provided in the
<experimental/> directory, but without such an
#include.
|
std::experimental::fundamentals_v4,
std::experimental::fundamentals_v5, etc., with the
most recent implemented version inlined into
std::experimental.
For the sake of improved portability between partial implementations of various C++ standards,
implementers and programmers are recommended to follow the guidelines in this section concerning feature-test macros.
Implementers who provide a new standard feature should define a macro with the recommended name,
in the same circumstances under which the feature is available (for example, taking into account relevant command-line options),
to indicate the presence of support for that feature.
Implementers should define that macro with the value specified in
the most recent version of this document that they have implemented.
The recommended macro name is "__cpp_lib_experimental_" followed by the string in the "Macro Name Suffix" column.
Programmers who wish to determine whether a feature is available in an implementation should base that determination on
the presence of the header (determined with __has_include(<header/name>)) and
the state of the macro with the recommended name.
(The absence of a tested feature may result in a program with decreased functionality, or the relevant functionality may be provided in a different way.
A program that strictly depends on support for a feature can just try to use the feature unconditionally;
presumably, on an implementation lacking necessary support, translation will fail.)
| Feature | Primary Section | Macro Name Suffix | Value | Header |
|---|---|---|---|---|
| Const-propagating wrapper | propagate_const
| 201505 | <experimental/propagate_const>
| |
| Generic scope guard and RAII wrapper | scope
| 201902 | <experimental/scope>
| |
| Invocation type traits | invocation_type |
201406 | <experimental/type_traits> |
|
| Detection metaprograms | detect |
201505 | <experimental/type_traits> |
|
Polymorphic allocator for std::function |
function_polymorphic_allocator |
202211 | <experimental/functional> |
|
| Polymorphic memory resources | memory_resources |
201803 | <experimental/memory_resouce> |
|
| Non-owning pointer wrapper | observer_ptr
| 201411 | <experimental/memory>
| |
| Delimited iterators | ostream_joiner |
201411 | <experimental/iterator> |
|
| Random sampling | sample |
201402 | <experimental/algorithm> |
|
Replacement for std::rand |
randint |
201511 | <experimental/random> |