Introduction

In this document, the phrase C++ Standard Library refers to the library described in ISO/IEC 14882:2020, clauses 16–32.

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.

Scope

This document describes extensions to the C++ Standard Library (). These extensions are classes and functions that are likely to be used widely within a program and/or on the interface boundaries between libraries written by different organizations.

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.

Normative references

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.

Terms and definitions

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:

General principles

Namespaces, headers, and modifications to standard classes

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:

This document does not define 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.

C++ library headers
  • <experimental/algorithm>
  • <experimental/functional>
  • <experimental/future>
  • <experimental/iterator>
  • <experimental/memory>
  • <experimental/memory_resource>
  • <experimental/propagate_const>
  • <experimental/random>
  • <experimental/scope>
  • <experimental/type_traits>
  • <experimental/utility>

This is the last in a series of revisions of this document planned by the C++ committee; while there are no plans to resume the series, any future versions will define their contents in std::experimental::fundamentals_v4, std::experimental::fundamentals_v5, etc., with the most recent implemented version inlined into std::experimental.

Feature-testing recommendations

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. Standing document SD-6 makes similar recommendations for ISO/IEC 14882:2020.

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.)

Significant features in this document
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>