Заголовок стандартной библиотеки <memory>
Этот заголовок входит в библиотеку управления динамической памятью.
Подключаемые заголовки |
|
|
(C++20) | Поддержка оператора трёхстороннего сравнения |
Классы |
|
Характеристики указателей |
|
|
(C++11) | предоставляет информацию о типах, подобных указателям (шаблон класса) |
Поддержка сборщика мусора |
|
|
(C++11)(удалён в C++23) | перечисляет модели безопасности указателей (перечисление) |
Аллокаторы |
|
| аллокатор по умолчанию (шаблон класса) |
|
|
(C++11) | предоставляет информацию о типах аллокаторов (шаблон класса) |
|
(C++23) | содержит адрес и фактический размер хранилища, выделенного с помощью allocate_at_least (шаблон класса) |
|
(C++11) | проверяет, поддерживает ли указанный тип конструирование с использованием аллокатора (шаблон класса) |
Неинициализированное хранилище |
|
|
(устарел в C++17)(удалён в C++20) | итератор, позволяющий стандартным алгоритмам сохранять результаты в неинициализированной памяти (шаблон класса) |
Умные указатели |
|
|
(C++11) | умный указатель с семантикой единоличного владения объектом (шаблон класса) |
|
(C++11) | умный указатель с семантикой совместного владения объектом (шаблон класса) |
|
(C++11) | слабая ссылка на объект, управляемый с помощью std::shared_ptr (шаблон класса) |
|
(устарел в C++11)(удалён в C++17) | умный указатель со строгой семантикой владения объектом (шаблон класса) |
Адаптеры умных указателей |
|
|
(C++23) | взаимодействует с функциями установки внешних указателей и сбрасывает умный указатель при уничтожении (шаблон класса) |
|
(C++23) | взаимодействует с функциями установки внешних указателей, получает начальное значение указателя из умного указателя и сбрасывает его при уничтожении (шаблон класса) |
Типы для проектирования составных классов |
|
|
(C++26) | обёртка, содержащая динамически выделенный объект с семантикой, подобной семантике значения (шаблон класса) |
|
(C++26) | полиморфная обёртка, содержащая динамически выделенный объект с семантикой, подобной семантике значения (шаблон класса) |
Вспомогательные классы |
|
|
(C++20) | атомарный разделяемый указатель (специализация шаблона класса) |
|
(C++20) | атомарный слабый указатель (специализация шаблона класса) |
|
(C++11) | предоставляет смешанное упорядочение разделяемых и слабых указателей на основе владельца (шаблон класса) |
|
(C++26) | предоставляет хеширование разделяемых и слабых указателей на основе владельца (класс) |
|
(C++26) | предоставляет сравнение на равенство разделяемых и слабых указателей разных типов на основе владельца (класс) |
|
(C++11) | позволяет объекту создать shared_ptr, ссылающийся на него самого (шаблон класса) |
|
(C++11) | исключение, выбрасываемое при обращении к weak_ptr, ссылающемуся на уже уничтоженный объект (класс) |
|
(C++11) | удалитель по умолчанию для unique_ptr (шаблон класса) |
|
(C++11) | поддержка хеширования для std::unique_ptr (специализация шаблона класса) |
|
(C++11) | поддержка хеширования для std::shared_ptr (специализация шаблона класса) |
|
(C++26) | поддержка хеширования для std::indirect (специализация шаблона класса) |
Предварительные объявления |
|
Определён в заголовке <functional> |
|
|---|---|
|
(C++11) | объект функции хеширования (шаблон класса) |
Определён в заголовке <atomic> |
|
|
(C++11) | шаблон класса atomic и специализации для типов bool, целочисленных типов, типов с плавающей запятой,(начиная с C++20) и указателей (шаблон класса) |
Теги |
|
|
(C++11) | тег для выбора конструкторов, учитывающих аллокатор (тег) |
Функции / функциональные сущности |
|
Конструирование с использованием аллокатора |
|
|
(C++20) | подготавливает список аргументов, соответствующий требуемому для данного типа варианту конструирования с использованием аллокатора (шаблон функции) |
|
(C++20) | создаёт объект заданного типа посредством конструирования с использованием аллокатора (шаблон функции) |
|
(C++20) | создаёт объект заданного типа в указанной области памяти посредством конструирования с использованием аллокатора (шаблон функции) |
Разное |
|
|
(C++20) | получает обычный указатель из типа, подобного указателю (шаблон функции) |
|
(C++11) | получает фактический адрес объекта, даже если оператор & перегружен (шаблон функции) |
|
(C++11) | выравнивает указатель в буфере (функция) |
|
(C++20) | сообщает компилятору, что указатель выровнен (шаблон функции) |
|
(C++26) | проверяет, указывает ли указатель на объект с выравниванием не меньше заданного значения (шаблон функции) |
Явное управление временем жизни |
|
|
(C++23) | неявно создаёт объекты в заданном хранилище, повторно используя представление объекта (шаблон функции) |
Поддержка сборщика мусора |
|
|
(C++11)(удалён в C++23) | объявляет, что объект нельзя освобождать (функция) |
|
(C++11)(удалён в C++23) | объявляет, что объект можно освобождать (шаблон функции) |
|
(C++11)(удалён в C++23) | объявляет, что область памяти не содержит отслеживаемых указателей (функция) |
|
(C++11)(удалён в C++23) | отменяет действие функции std::declare_no_pointers (функция) |
|
(C++11)(удалён в C++23) | возвращает текущую модель безопасности указателей (функция) |
Специализированные алгоритмы |
|
| копирует диапазон объектов в неинициализированную область памяти (шаблон функции и функциональный объект-алгоритм) |
|
|
(C++20) | |
|
(C++11) | копирует заданное количество объектов в неинициализированную область памяти (шаблон функции и функциональный объект-алгоритм) |
|
(C++20) | |
| копирует объект в неинициализированную область памяти, заданную диапазоном (шаблон функции и функциональный объект-алгоритм) |
|
|
(C++20) | |
| копирует объект в неинициализированную область памяти, заданную начальной точкой и количеством элементов (шаблон функции и функциональный объект-алгоритм) |
|
|
(C++20) | |
|
(C++17) | перемещает диапазон объектов в неинициализированную область памяти (шаблон функции и функциональный объект-алгоритм) |
|
(C++20) | |
|
(C++17) | перемещает заданное количество объектов в неинициализированную область памяти (шаблон функции и функциональный объект-алгоритм) |
|
(C++20) | |
|
(C++17) | создаёт объекты путём инициализации по умолчанию в неинициализированной области памяти, заданной диапазоном (шаблон функции и функциональный объект-алгоритм) |
|
(C++20) | |
|
(C++17) | создаёт объекты путём инициализации по умолчанию в неинициализированной области памяти, заданной начальной точкой и количеством элементов (шаблон функции и функциональный объект-алгоритм) |
|
(C++20) | |
|
(C++17) | создаёт объекты путём инициализации значением в неинициализированной области памяти, заданной диапазоном (шаблон функции и функциональный объект-алгоритм) |
|
(C++20) | |
|
(C++17) | создаёт объекты путём инициализации значением в неинициализированной области памяти, заданной начальной точкой и количеством элементов (шаблон функции и функциональный объект-алгоритм) |
|
(C++20) | |
|
(C++20) | создаёт объект по заданному адресу (шаблон функции и функциональный объект-алгоритм) |
|
(C++20) | |
|
(C++17) | уничтожает объект по заданному адресу (шаблон функции и функциональный объект-алгоритм) |
|
(C++20) | |
|
(C++17) | уничтожает диапазон объектов (шаблон функции и функциональный объект-алгоритм) |
|
(C++20) | |
|
(C++17) | уничтожает заданное количество объектов в диапазоне (шаблон функции и функциональный объект алгоритма) |
|
(C++20) | |
|
(устарело в C++17)(удалено в C++20) | получает неинициализированную память (шаблон функции) |
|
(устарело в C++17)(удалено в C++20) | освобождает неинициализированную память (шаблон функции) |
Нечлены-операции умных указателей |
|
|
(C++14)(C++20) | создает уникальный указатель, управляющий новым объектом (шаблон функции) |
|
(удалено в C++20)(C++20) | сравнивает с другим unique_ptr или с nullptr (шаблон функции) |
|
(C++20) | создает разделяемый указатель, управляющий новым объектом (шаблон функции) |
|
(C++20) | создает разделяемый указатель, управляющий новым объектом, выделенным с помощью аллокатора (шаблон функции) |
|
(C++17) | применяет static_cast, dynamic_cast, const_cast или reinterpret_cast к сохраненному указателю (шаблон функции) |
| возвращает удалитель указанного типа, если он принадлежит указателю (шаблон функции) |
|
|
(удалено в C++20)(удалено в C++20)(удалено в C++20)(удалено в C++20)(удалено в C++20)(C++20) | сравнивает с другим shared_ptr или с nullptr (шаблон функции) |
| выводит значение сохраненного указателя в выходной поток (шаблон функции) |
|
|
(C++20) | выводит значение управляемого указателя в выходной поток (шаблон функции) |
|
(C++11) | специализирует алгоритм std::swap (шаблон функции) |
|
(C++11) | специализирует алгоритм std::swap (шаблон функции) |
|
(C++11) | специализирует алгоритм std::swap (шаблон функции) |
Создание адаптеров умных указателей |
|
|
(C++23) | создает out_ptr_t со связанным умным указателем и аргументами сброса (шаблон функции) |
|
(C++23) | создает inout_ptr_t со связанным умным указателем и аргументами сброса (шаблон функции) |
|
(устарело в C++20)(удалено в C++26) | специализирует атомарные операции для std::shared_ptr (шаблон функции) |
Обзор
#include <compare>
namespace std {
// pointer Traits
template<class Ptr>
struct pointer_traits; // freestanding
template<class T>
struct pointer_traits<T*>; // freestanding
// pointer conversion
template<class T>
constexpr T* to_address(T* p) noexcept; // freestanding
template<class Ptr>
constexpr auto to_address(const Ptr& p) noexcept; // freestanding
// pointer alignment
void* align(size_t alignment, size_t size, void*& ptr, size_t& space); // freestanding
template<size_t N, class T>
constexpr T* assume_aligned(T* ptr); // freestanding
template<size_t Alignment, class T>
bool is_sufficiently_aligned(T* ptr);
// explicit lifetime management
template<class T>
T* start_lifetime_as(void* p) noexcept; // freestanding
template<class T>
const T* start_lifetime_as(const void* p) noexcept; // freestanding
template<class T>
volatile T* start_lifetime_as(volatile void* p) noexcept; // freestanding
template<class T>
const volatile T* start_lifetime_as(const volatile void* p) noexcept; // freestanding
template<class T>
T* start_lifetime_as_array(void* p, size_t n) noexcept; // freestanding
template<class T>
const T* start_lifetime_as_array(const void* p, size_t n) noexcept; // freestanding
template<class T>
volatile T* start_lifetime_as_array(volatile void* p,
size_t n) noexcept; // freestanding
template<class T>
const volatile T* start_lifetime_as_array(const volatile void* p, // freestanding
size_t n) noexcept;
template<class T>
T* trivially_relocate(T* first, T* last, T* result); // freestanding
template<class T>
constexpr T* relocate(T* first, T* last, T* result); // freestanding
// allocator argument tag
struct allocator_arg_t
{
explicit allocator_arg_t() = default;
}; // freestanding
inline constexpr allocator_arg_t allocator_arg{}; // freestanding
// uses_allocator
template<class T, class Alloc>
struct uses_allocator; // freestanding
// uses_allocator
template<class T, class Alloc>
constexpr bool uses_allocator_v = uses_allocator<T, Alloc>::value; // freestanding
// uses-allocator construction
template<class T, class Alloc, class... Args>
constexpr auto uses_allocator_construction_args(const Alloc& alloc, // freestanding
Args&&... args) noexcept;
template<class T, class Alloc, class Tuple1, class Tuple2>
constexpr auto uses_allocator_construction_args(const Alloc& alloc, // freestanding
piecewise_construct_t,
Tuple1&& x,
Tuple2&& y) noexcept;
template<class T, class Alloc>
constexpr auto uses_allocator_construction_args(
const Alloc& alloc) noexcept; // freestanding
template<class T, class Alloc, class U, class V>
constexpr auto uses_allocator_construction_args(const Alloc& alloc, // freestanding
U&& u,
V&& v) noexcept;
template<class T, class Alloc, class U, class V>
constexpr auto uses_allocator_construction_args(const Alloc& alloc, // freestanding
pair<U, V>& pr) noexcept;
template<class T, class Alloc, class U, class V>
constexpr auto uses_allocator_construction_args(const Alloc& alloc, // freestanding
const pair<U, V>& pr) noexcept;
template<class T, class Alloc, class U, class V>
constexpr auto uses_allocator_construction_args(const Alloc& alloc, // freestanding
pair<U, V>&& pr) noexcept;
template<class T, class Alloc, class U, class V>
constexpr auto uses_allocator_construction_args(const Alloc& alloc, // freestanding
const pair<U, V>&& pr) noexcept;
template<class T, class Alloc, /*pair-like*/ P>
constexpr auto uses_allocator_construction_args(const Alloc& alloc, // freestanding
P&& p) noexcept;
template<class T, class Alloc, class U>
constexpr auto uses_allocator_construction_args(const Alloc& alloc, // freestanding
U&& u) noexcept;
template<class T, class Alloc, class... Args>
constexpr T make_obj_using_allocator(const Alloc& alloc,
Args&&... args); // freestanding
template<class T, class Alloc, class... Args>
constexpr T* uninitialized_construct_using_allocator(T* p, // freestanding
const Alloc& alloc,
Args&&... args);
// allocator Traits
template<class Alloc>
struct allocator_traits; // freestanding
template<class Pointer, class SizeType = size_t>
struct allocation_result
{ // freestanding
Pointer ptr;
SizeType count;
};
// the default allocator
template<class T>
class allocator;
template<class T, class U>
constexpr bool operator==(const allocator<T>&, const allocator<U>&) noexcept;
// addressof
template<class T>
constexpr T* addressof(T& r) noexcept; // freestanding
template<class T>
const T* addressof(const T&&) = delete; // freestanding
// specialized algorithms
// special memory concepts
template<class I>
concept nothrow-input-iterator = /* see description */; // exposition-only
template<class I>
concept nothrow-forward-iterator = /* see description */; // exposition-only
template<class I>
concept nothrow-bidirectional-iterator = /* see description */; // exposition-only
template<class I>
concept nothrow-random-access-iterator = /* see description */; // exposition-only
template<class S, class I>
concept nothrow-sentinel-for = /* see description */; // exposition-only
template<class S, class I>
concept nothrow-sized-sentinel-for = /* see description */; // exposition-only
template<class R>
concept nothrow-input-range = /* see description */; // exposition-only
template<class R>
concept nothrow-forward-range = /* see description */; // exposition-only
template<class R>
concept nothrow-bidirectional-range = /* see description */; // exposition-only
template<class R>
concept nothrow-random-access-range = /* see description */; // exposition-only
template<class R>
concept nothrow-sized-random-access-range = /* see description */; // exposition-only
template<class NoThrowForwardIter>
constexpr void uninitialized_default_construct(NoThrowForwardIter first, // freestanding
NoThrowForwardIter last);
template<class ExecutionPolicy, class NoThrowForwardIter>
void uninitialized_default_construct(ExecutionPolicy&& exec, // freestanding-deleted
NoThrowForwardIter first,
NoThrowForwardIter last);
template<class NoThrowForwardIter, class Size>
constexpr NoThrowForwardIter uninitialized_default_construct_n(NoThrowForwardIter first,
Size n); // freestanding
template<class ExecutionPolicy, class NoThrowForwardIter, class Size>
NoThrowForwardIter uninitialized_default_construct_n(
ExecutionPolicy&& exec, // freestanding-deleted
NoThrowForwardIter first,
Size n);
namespace ranges {
template<no-throw-forward-iterator I, no-throw-sentinel-for<I> S>
requires default_initializable<iter_value_t<I>>
constexpr I uninitialized_default_construct(I first, S last); // freestanding
template<no-throw-forward-range R>
requires default_initializable<range_value_t<R>>
constexpr borrowed_iterator_t<R> uninitialized_default_construct(
R&& r); // freestanding
template<no-throw-forward-iterator I>
requires default_initializable<iter_value_t<I>>
constexpr I uninitialized_default_construct_n(I first, // freestanding
iter_difference_t<I> n);
template<execution-policy Ep, nothrow-random-access-iterator I,
nothrow-sized-sentinel-for <I> S>
requires default_initializable<iter_value_t<I>>
I uninitialized_default_construct(Ep&& exec, I first, S last); // freestanding-deleted
template<execution-policy Ep, nothrow-sized-random-access-range R>
requires default_initializable<range_value_t<R>>
borrowed_iterator_t<R> uninitialized_default_construct // freestanding-deleted
(Ep&& exec, R&& r);
template<execution-policy Ep, nothrow-random-access-iterator I>
requires default_initializable<iter_value_t<I>>
I uninitialized_default_construct_n(Ep&& exec, I first, // freestanding-deleted
iter_difference_t<I> n);
}
template<class NoThrowForwardIter>
constexpr void uninitialized_value_construct(NoThrowForwardIter first, // freestanding
NoThrowForwardIter last);
template<class ExecutionPolicy, class NoThrowForwardIter>
void uninitialized_value_construct(ExecutionPolicy&& exec, // freestanding-deleted
NoThrowForwardIter first,
NoThrowForwardIter last);
template<class NoThrowForwardIter, class Size>
constexpr NoThrowForwardIter uninitialized_value_construct_n(NoThrowForwardIter first,
Size n); // freestanding
template<class ExecutionPolicy, class NoThrowForwardIter, class Size>
NoThrowForwardIter uninitialized_value_construct_n(
ExecutionPolicy&& exec, // freestanding-deleted
NoThrowForwardIter first,
Size n);
namespace ranges {
template<no-throw-forward-iterator I, no-throw-sentinel-for<I> S>
requires default_initializable<iter_value_t<I>>
constexpr I uninitialized_value_construct(I first, S last); // freestanding
template<no-throw-forward-range R>
requires default_initializable<range_value_t<R>>
constexpr borrowed_iterator_t<R> uninitialized_value_construct(R&& r); // freestanding
template<no-throw-forward-iterator I>
requires default_initializable<iter_value_t<I>>
constexpr I uninitialized_value_construct_n(I first, // freestanding
iter_difference_t<I> n);
template<execution-policy Ep, nothrow-random-access-iterator I,
nothrow-sized-sentinel-for <I> S>
requires default_initializable<iter_value_t<I>>
I uninitialized_value_construct(Ep&& exec, I first, S last); // freestanding-deleted
template<execution-policy Ep, nothrow-sized-random-access-range R>
requires default_initializable<range_value_t<R>>
borrowed_iterator_t<R> uninitialized_value_construct // freestanding-deleted
(Ep&& exec, R&& r);
template<execution-policy Ep, nothrow-random-access-iterator I>
requires default_initializable<iter_value_t<I>>
I uninitialized_value_construct_n(Ep&& exec, I first, // freestanding-deleted
iter_difference_t<I> n);
}
template<class InputIter, class NoThrowForwardIter>
constexpr NoThrowForwardIter uninitialized_copy(InputIter first, // freestanding
InputIter last,
NoThrowForwardIter result);
template<class ExecutionPolicy, class ForwardIter, class NoThrowForwardIter>
NoThrowForwardIter uninitialized_copy(ExecutionPolicy&& exec, // freestanding-deleted
ForwardIter first,
ForwardIter last,
NoThrowForwardIter result);
template<class InputIter, class Size, class NoThrowForwardIter>
constexpr NoThrowForwardIter uninitialized_copy_n(InputIter first, // freestanding
Size n,
NoThrowForwardIter result);
template<class ExecutionPolicy,
class ForwardIter,
class Size,
class NoThrowForwardIter>
NoThrowForwardIter uninitialized_copy_n(ExecutionPolicy&& exec, // freestanding-deleted
ForwardIter first,
Size n,
NoThrowForwardIter result);
namespace ranges {
template<class I, class O>
using uninitialized_copy_result = in_out_result<I, O>; // freestanding
template<input_iterator I,
sentinel_for<I> S1,
no-throw-forward-iterator O,
no-throw-sentinel-for<O> S2>
requires constructible_from<iter_value_t<O>, iter_reference_t<I>>
constexpr uninitialized_copy_result<I, O>
uninitialized_copy(I ifirst, S1 ilast, O ofirst, S2 olast); // freestanding
template<input_range IR, no-throw-forward-range OR>
requires constructible_from<range_value_t<OR>, range_reference_t<IR>>
constexpr uninitialized_copy_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>
uninitialized_copy(IR&& in_range, OR&& out_range); // freestanding
template<class I, class O>
using uninitialized_copy_n_result = in_out_result<I, O>; // freestanding
template<input_iterator I,
no-throw-forward-iterator O,
no-throw-sentinel-for<O> S>
requires constructible_from<iter_value_t<O>, iter_reference_t<I>>
constexpr uninitialized_copy_n_result<I, O> uninitialized_copy_n(
I ifirst,
iter_difference_t<I> n, // freestanding
O ofirst,
S olast);
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S1,
nothrow-random-access-iterator O, nothrow-sized-sentinel-for <O> S2>
requires constructible_from<iter_value_t<O>, iter_reference_t<I>>
uninitialized_copy_result<I, O>
uninitialized_copy(Ep&& exec, I ifirst, S1 ilast, // freestanding-deleted
O ofirst, S2 olast);
template<execution-policy Ep, sized-random-access-range IR,
nothrow-sized-random-access-range OR>
requires constructible_from<range_value_t<OR>, range_reference_t<IR>>
uninitialized_copy_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>
uninitialized_copy(Ep&& exec, IR&& in_range, OR&& out_range); // freestanding-deleted
template<execution-policy Ep, random_access_iterator I,
nothrow-random-access-iterator O, nothrow-sized-sentinel-for <O> S>
requires constructible_from<iter_value_t<O>, iter_reference_t<I>>
uninitialized_copy_n_result<I, O>
uninitialized_copy_n(Ep&& exec, I ifirst, // freestanding-deleted
iter_difference_t<I> n, O ofirst, S olast);
}
template<class InputIter, class NoThrowForwardIter>
constexpr NoThrowForwardIter uninitialized_move(InputIter first, // freestanding
InputIter last,
NoThrowForwardIter result);
template<class ExecutionPolicy, class ForwardIter, class NoThrowForwardIter>
NoThrowForwardIter uninitialized_move(ExecutionPolicy&& exec, // freestanding-deleted
ForwardIter first,
ForwardIter last,
NoThrowForwardIter result);
template<class InputIter, class Size, class NoThrowForwardIter>
constexpr pair<InputIter, NoThrowForwardIter> uninitialized_move_n(
InputIter first,
Size n, // freestanding
NoThrowForwardIter result);
template<class ExecutionPolicy, class ForwardIter, class Size, class NoThrowForwardIter>
pair<ForwardIter, NoThrowForwardIter> uninitialized_move_n(
ExecutionPolicy&& exec, // freestanding-deleted
ForwardIter first,
Size n,
NoThrowForwardIter result);
namespace ranges {
template<class I, class O>
using uninitialized_move_result = in_out_result<I, O>; // freestanding
template<input_iterator I,
sentinel_for<I> S1,
no-throw-forward-iterator O,
no-throw-sentinel-for<O> S2>
requires constructible_from<iter_value_t<O>, iter_rvalue_reference_t<I>>
constexpr uninitialized_move_result<I, O>
uninitialized_move(I ifirst, S1 ilast, O ofirst, S2 olast); // freestanding
template<input_range IR, no-throw-forward-range OR>
requires constructible_from<range_value_t<OR>, range_rvalue_reference_t<IR>>
constexpr uninitialized_move_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>
uninitialized_move(IR&& in_range, OR&& out_range); // freestanding
template<class I, class O>
using uninitialized_move_n_result = in_out_result<I, O>; // freestanding
template<input_iterator I,
no-throw-forward-iterator O,
no-throw-sentinel-for<O> S>
requires constructible_from<iter_value_t<O>, iter_rvalue_reference_t<I>>
constexpr uninitialized_move_n_result<I, O> uninitialized_move_n(
I ifirst,
iter_difference_t<I> n, // freestanding
O ofirst,
S olast);
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S1,
nothrow-random-access-iterator O, nothrow-sized-sentinel-for <O> S2>
requires constructible_from<iter_value_t<O>, iter_rvalue_reference_t<I>>
uninitialized_move_result<I, O>
uninitialized_move(Ep&& exec, I ifirst, S1 ilast, // freestanding-deleted
O ofirst, S2 olast);
template<execution-policy Ep, sized-random-access-range IR,
nothrow-sized-random-access-range OR>
requires constructible_from<range_value_t<OR>, range_rvalue_reference_t<IR>>
uninitialized_move_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>
uninitialized_move(Ep&& exec, IR&& in_range, OR&& out_range); // freestanding-deleted
template<execution-policy Ep, random_access_iterator I,
nothrow-random-access-iterator O, nothrow-sized-sentinel-for <O> S>
requires constructible_from<iter_value_t<O>, iter_rvalue_reference_t<I>>
uninitialized_move_n_result<I, O>
uninitialized_move_n(Ep&& exec, I ifirst, // freestanding-deleted
iter_difference_t<I> n, O ofirst, S olast);
}
template<class NoThrowForwardIter, class T>
constexpr void uninitialized_fill(NoThrowForwardIter first, // freestanding
NoThrowForwardIter last,
const T& x);
template<class ExecutionPolicy, class NoThrowForwardIter, class T>
void uninitialized_fill(ExecutionPolicy&& exec, // freestanding-deleted
NoThrowForwardIter first,
NoThrowForwardIter last,
const T& x);
template<class NoThrowForwardIter, class Size, class T>
constexpr NoThrowForwardIter uninitialized_fill_n(NoThrowForwardIter first,
Size n,
const T& x); // freestanding
template<class ExecutionPolicy, class NoThrowForwardIter, class Size, class T>
NoThrowForwardIter uninitialized_fill_n(ExecutionPolicy&& exec, // freestanding-deleted
NoThrowForwardIter first,
Size n,
const T& x);
namespace ranges {
template<no-throw-forward-iterator I, no-throw-sentinel-for<I> S, class T>
requires constructible_from<iter_value_t<I>, const T&>
constexpr I uninitialized_fill(I first, S last, const T& x); // freestanding
template<no-throw-forward-range R, class T>
requires constructible_from<range_value_t<R>, const T&>
constexpr borrowed_iterator_t<R> uninitialized_fill(R&& r,
const T& x); // freestanding
template<no-throw-forward-iterator I, class T>
requires constructible_from<iter_value_t<I>, const T&>
constexpr I uninitialized_fill_n(I first, // freestanding
iter_difference_t<I> n,
const T& x);
template<execution-policy Ep, nothrow-random-access-iterator I,
nothrow-sized-sentinel-for <I> S, class T = iter_value_t<I>>
requires constructible_from<iter_value_t<I>, const T&>
I uninitialized_fill(Ep&& exec, I first, S last, const T& x); // freestanding-deleted
template<execution-policy Ep, nothrow-sized-random-access-range R,
class T = range_value_t<R>>
requires constructible_from<range_value_t<R>, const T&>
borrowed_iterator_t<R> uninitialized_fill(Ep&& exec, R&& r, // freestanding-deleted
const T& x);
template<execution-policy Ep, nothrow-random-access-iterator I,
class T = iter_value_t<I>>
requires constructible_from<iter_value_t<I>, const T&>
I uninitialized_fill_n(Ep&& exec, I first, // freestanding-deleted
iter_difference_t<I> n, const T& x);
}
// construct_at
template<class T, class... Args>
constexpr T* construct_at(T* location, Args&&... args); // freestanding
namespace ranges {
template<class T, class... Args>
constexpr T* construct_at(T* location, Args&&... args); // freestanding
}
// destroy
template<class T>
constexpr void destroy_at(T* location); // freestanding
template<class NoThrowForwardIter>
constexpr void destroy(NoThrowForwardIter first, // freestanding
NoThrowForwardIter last);
template<class ExecutionPolicy, class NoThrowForwardIter>
void destroy(ExecutionPolicy&& exec, // freestanding-deleted
NoThrowForwardIter first,
NoThrowForwardIter last);
template<class NoThrowForwardIter, class Size>
constexpr NoThrowForwardIter destroy_n(NoThrowForwardIter first, // freestanding
Size n);
template<class ExecutionPolicy, class NoThrowForwardIter, class Size>
NoThrowForwardIter destroy_n(ExecutionPolicy&& exec, // freestanding-deleted
NoThrowForwardIter first,
Size n);
namespace ranges {
template<destructible T>
constexpr void destroy_at(T* location) noexcept; // freestanding
template<no-throw-input-iterator I, no-throw-sentinel-for<I> S>
requires destructible<iter_value_t<I>>
constexpr I destroy(I first, S last) noexcept; // freestanding
template<no-throw-input-range R>
requires destructible<range_value_t<R>>
constexpr borrowed_iterator_t<R> destroy(R&& r) noexcept; // freestanding
template<no-throw-input-iterator I>
requires destructible<iter_value_t<I>>
constexpr I destroy_n(I first, iter_difference_t<I> n) noexcept; // freestanding
template<execution-policy Ep, nothrow-random-access-iterator I,
nothrow-sized-sentinel-for <I> S>
requires destructible<iter_value_t<I>>
I destroy(Ep&& exec, I first, S last); // freestanding-deleted
template<execution-policy Ep, nothrow-sized-random-access-range R>
requires destructible<range_value_t<R>>
borrowed_iterator_t<R> destroy(Ep&& exec, R&& r); // freestanding-deleted
template<execution-policy Ep, nothrow-random-access-iterator I>
requires destructible<iter_value_t<I>>
I destroy_n(Ep&& exec, I first, iter_difference_t<I> n); // freestanding-deleted
}
// class template unique_ptr
template<class T>
struct default_delete; // freestanding
template<class T>
struct default_delete<T[]>; // freestanding
template<class T, class D = default_delete<T>>
class unique_ptr; // freestanding
template<class T, class D>
class unique_ptr<T[], D>; // freestanding
template<class T, class... Args>
constexpr unique_ptr<T> make_unique(Args&&... args); // T is not array
template<class T>
constexpr unique_ptr<T> make_unique(size_t n); // T is U[]
template<class T, class... Args>
/* unspecified */ make_unique(Args&&...) = delete; // T is U[N]
template<class T>
constexpr unique_ptr<T> make_unique_for_overwrite(); // T is not array
template<class T>
constexpr unique_ptr<T> make_unique_for_overwrite(size_t n); // T is U[]
template<class T, class... Args>
/* unspecified */ make_unique_for_overwrite(Args&&...) = delete; // T is U[N]
template<class T, class D>
constexpr void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept; // freestanding
template<class T1, class D1, class T2, class D2>
constexpr bool operator==(const unique_ptr<T1, D1>& x, // freestanding
const unique_ptr<T2, D2>& y);
template<class T1, class D1, class T2, class D2>
constexpr bool operator<(const unique_ptr<T1, D1>& x,
const unique_ptr<T2, D2>& y); // freestanding
template<class T1, class D1, class T2, class D2>
constexpr bool operator>(const unique_ptr<T1, D1>& x,
const unique_ptr<T2, D2>& y); // freestanding
template<class T1, class D1, class T2, class D2>
constexpr bool operator<=(const unique_ptr<T1, D1>& x,
const unique_ptr<T2, D2>& y); // freestanding
template<class T1, class D1, class T2, class D2>
constexpr bool operator>=(const unique_ptr<T1, D1>& x,
const unique_ptr<T2, D2>& y); // freestanding
template<class T1, class D1, class T2, class D2>
requires three_way_comparable_with<typename unique_ptr<T1, D1>::pointer,
typename unique_ptr<T2, D2>::pointer>
constexpr compare_three_way_result_t<typename unique_ptr<T1, D1>::pointer,
typename unique_ptr<T2, D2>::pointer>
operator<=>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); // freestanding
template<class T, class D>
constexpr bool operator==(const unique_ptr<T, D>& x,
nullptr_t) noexcept; // freestanding
template<class T, class D>
constexpr bool operator<(const unique_ptr<T, D>& x, nullptr_t); // freestanding
template<class T, class D>
constexpr bool operator<(nullptr_t, const unique_ptr<T, D>& y); // freestanding
template<class T, class D>
constexpr bool operator>(const unique_ptr<T, D>& x, nullptr_t); // freestanding
template<class T, class D>
constexpr bool operator>(nullptr_t, const unique_ptr<T, D>& y); // freestanding
template<class T, class D>
constexpr bool operator<=(const unique_ptr<T, D>& x, nullptr_t); // freestanding
template<class T, class D>
constexpr bool operator<=(nullptr_t, const unique_ptr<T, D>& y); // freestanding
template<class T, class D>
constexpr bool operator>=(const unique_ptr<T, D>& x, nullptr_t); // freestanding
template<class T, class D>
constexpr bool operator>=(nullptr_t, const unique_ptr<T, D>& y); // freestanding
template<class T, class D>
requires three_way_comparable<typename unique_ptr<T, D>::pointer>
constexpr compare_three_way_result_t<typename unique_ptr<T, D>::pointer> operator<=>(
const unique_ptr<T, D>& x,
nullptr_t); // freestanding
template<class E, class T, class Y, class D>
basic_ostream<E, T>& operator<<(basic_ostream<E, T>& os, const unique_ptr<Y, D>& p);
// class bad_weak_ptr
class bad_weak_ptr;
// class template shared_ptr
template<class T>
class shared_ptr;
// shared_ptr creation
template<class T, class... Args>
constexpr shared_ptr<T> make_shared(Args&&... args); // T is not array
template<class T, class A, class... Args>
sconstexpr hared_ptr<T> allocate_shared(const A& a, Args&&... args); // T is not array
template<class T>
constexpr shared_ptr<T> make_shared(size_t N); // T is U[]
template<class T, class A>
constexpr shared_ptr<T> allocate_shared(const A& a, size_t N); // T is U[]
template<class T>
constexpr shared_ptr<T> make_shared(); // T is U[N]
template<class T, class A>
constexpr shared_ptr<T> allocate_shared(const A& a); // T is U[N]
template<class T>
constexpr shared_ptr<T> make_shared(size_t N, const remove_extent_t<T>& u); // T is U[]
template<class T, class A>
constexpr shared_ptr<T> allocate_shared(const A& a,
size_t N,
const remove_extent_t<T>& u); // T is U[]
template<class T>
constexpr shared_ptr<T> make_shared(const remove_extent_t<T>& u); // T is U[N]
template<class T, class A>
constexpr shared_ptr<T> allocate_shared(const A& a,
const remove_extent_t<T>& u); // T is U[N]
template<class T>
constexpr shared_ptr<T> make_shared_for_overwrite(); // T is not U[]
template<class T, class A>
constexpr shared_ptr<T> allocate_shared_for_overwrite(const A& a); // T is not U[]
template<class T>
constexpr shared_ptr<T> make_shared_for_overwrite(size_t N); // T is U[]
template<class T, class A>
constexpr shared_ptr<T> allocate_shared_for_overwrite(const A& a, size_t N); // T is U[]
// shared_ptr comparisons
template<class T, class U>
constexpr bool operator==(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
template<class T, class U>
constexpr strong_ordering operator<=>(const shared_ptr<T>& a,
const shared_ptr<U>& b) noexcept;
template<class T>
constexpr bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept;
template<class T>
constexpr strong_ordering operator<=>(const shared_ptr<T>& x, nullptr_t) noexcept;
// shared_ptr specialized algorithms
template<class T>
constexpr void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept;
// shared_ptr casts
template<class T, class U>
constexpr shared_ptr<T> static_pointer_cast(const shared_ptr<U>& r) noexcept;
template<class T, class U>
constexpr shared_ptr<T> static_pointer_cast(shared_ptr<U>&& r) noexcept;
template<class T, class U>
constexpr shared_ptr<T> dynamic_pointer_cast(const shared_ptr<U>& r) noexcept;
template<class T, class U>
constexpr shared_ptr<T> dynamic_pointer_cast(shared_ptr<U>&& r) noexcept;
template<class T, class U>
constexpr shared_ptr<T> const_pointer_cast(const shared_ptr<U>& r) noexcept;
template<class T, class U>
constexpr shared_ptr<T> const_pointer_cast(shared_ptr<U>&& r) noexcept;
template<class T, class U>
shared_ptr<T> reinterpret_pointer_cast(const shared_ptr<U>& r) noexcept;
template<class T, class U>
shared_ptr<T> reinterpret_pointer_cast(shared_ptr<U>&& r) noexcept;
// shared_ptr get_deleter
template<class D, class T>
constexpr D* get_deleter(const shared_ptr<T>& p) noexcept;
// shared_ptr I/O
template<class E, class T, class Y>
basic_ostream<E, T>& operator<<(basic_ostream<E, T>& os, const shared_ptr<Y>& p);
// class template weak_ptr
template<class T>
class weak_ptr;
// weak_ptr specialized algorithms
template<class T>
constexpr void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
// class template owner_less
template<class T = void>
struct owner_less;
// struct owner_hash
struct owner_hash;
// struct owner_equal
struct owner_equal;
// class template enable_shared_from_this
template<class T>
class enable_shared_from_this;
// hash support
template<class T>
struct hash; // freestanding
template<class T, class D>
struct hash<unique_ptr<T, D>>; // freestanding
template<class T>
struct hash<shared_ptr<T>>;
// atomic smart pointers
template<class T>
struct atomic; // freestanding
template<class T>
struct atomic<shared_ptr<T>>;
template<class T>
struct atomic<weak_ptr<T>>;
// class template out_ptr_t
template<class Smart, class Pointer, class... Args>
class out_ptr_t; // freestanding
// function template out_ptr
template<class Pointer = void, class Smart, class... Args>
constexpr auto out_ptr(Smart& s, Args&&... args); // freestanding
// class template inout_ptr_t
template<class Smart, class Pointer, class... Args>
class inout_ptr_t; // freestanding
// function template inout_ptr
template<class Pointer = void, class Smart, class... Args>
constexpr auto inout_ptr(Smart& s, Args&&... args); // freestanding
// class template indirect
template<class T, class Allocator = allocator<T>>
class indirect;
// hash support
template<class T, class Alloc>
struct hash<indirect<T, Alloc>>;
// class template polymorphic
template<class T, class Allocator = allocator<T>>
class polymorphic;
namespace pmr {
template<class T>
using indirect = indirect<T, polymorphic_allocator<T>>;
template<class T>
using polymorphic = polymorphic<T, polymorphic_allocator<T>>;
}
}
Шаблон класса std::pointer_traits
namespace std {
template<class Ptr>
struct pointer_traits
{
/* see description */;
};
template<class T>
struct pointer_traits<T*>
{
using pointer = T*;
using element_type = T;
using difference_type = ptrdiff_t;
template<class U>
using rebind = U*;
static constexpr pointer pointer_to(/* see description */ r) noexcept;
};
}
Класс std::allocator_arg_t
namespace std {
struct allocator_arg_t { explicit allocator_arg_t() = default; };
inline constexpr allocator_arg_t allocator_arg{};
}
Шаблон класса std::allocator_traits
namespace std {
template<class Alloc>
struct allocator_traits
{
using allocator_type = Alloc;
using value_type = typename Alloc::value_type;
using pointer = /* see description */;
using const_pointer = /* see description */;
using void_pointer = /* see description */;
using const_void_pointer = /* see description */;
using difference_type = /* see description */;
using size_type = /* see description */;
using propagate_on_container_copy_assignment = /* see description */;
using propagate_on_container_move_assignment = /* see description */;
using propagate_on_container_swap = /* see description */;
using is_always_equal = /* see description */;
template<class T>
using rebind_alloc = /* see description */;
template<class T>
using rebind_traits = allocator_traits<rebind_alloc<T>>;
static constexpr pointer allocate(Alloc& a, size_type n);
static constexpr pointer allocate(Alloc& a, size_type n, const_void_pointer hint);
static constexpr allocation_result<pointer, size_type> allocate_at_least(Alloc& a,
size_type n);
static constexpr void deallocate(Alloc& a, pointer p, size_type n);
template<class T, class... Args>
static constexpr void construct(Alloc& a, T* p, Args&&... args);
template<class T>
static constexpr void destroy(Alloc& a, T* p);
static constexpr size_type max_size(const Alloc& a) noexcept;
static constexpr Alloc select_on_container_copy_construction(const Alloc& rhs);
};
}
Шаблон класса std::allocator
namespace std {
template<class T>
class allocator
{
public:
using value_type = T;
using size_type = size_t;
using difference_type = ptrdiff_t;
using propagate_on_container_move_assignment = true_type;
constexpr allocator() noexcept;
constexpr allocator(const allocator&) noexcept;
template<class U>
constexpr allocator(const allocator<U>&) noexcept;
constexpr ~allocator();
constexpr allocator& operator=(const allocator&) = default;
constexpr T* allocate(size_t n);
constexpr allocation_result<T*> allocate_at_least(size_t n);
constexpr void deallocate(T* p, size_t n);
};
}
Шаблон класса std::default_delete
namespace std {
template<class T>
struct default_delete
{
constexpr default_delete() noexcept = default;
template<class U>
constexpr default_delete(const default_delete<U>&) noexcept;
constexpr void operator()(T*) const;
};
template<class T>
struct default_delete<T[]>
{
constexpr default_delete() noexcept = default;
template<class U>
constexpr default_delete(const default_delete<U[]>&) noexcept;
template<class U>
constexpr void operator()(U* ptr) const;
};
}
Шаблон класса std::unique_ptr
namespace std {
template<class T, class D = default_delete<T>>
class unique_ptr
{
public:
using pointer = /* see description */;
using element_type = T;
using deleter_type = D;
// constructors
constexpr unique_ptr() noexcept;
constexpr explicit unique_ptr(type_identity_t<pointer> p) noexcept;
constexpr unique_ptr(type_identity_t<pointer> p, /* see description */ d1) noexcept;
constexpr unique_ptr(type_identity_t<pointer> p, /* see description */ d2) noexcept;
constexpr unique_ptr(unique_ptr&& u) noexcept;
constexpr unique_ptr(nullptr_t) noexcept;
template<class U, class E>
constexpr unique_ptr(unique_ptr<U, E>&& u) noexcept;
// destructor
constexpr ~unique_ptr();
// assignment
constexpr unique_ptr& operator=(unique_ptr&& u) noexcept;
template<class U, class E>
constexpr unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
constexpr unique_ptr& operator=(nullptr_t) noexcept;
// observers
constexpr add_lvalue_reference_t<T> operator*() const noexcept(/* see description */);
constexpr pointer operator->() const noexcept;
constexpr pointer get() const noexcept;
constexpr deleter_type& get_deleter() noexcept;
constexpr const deleter_type& get_deleter() const noexcept;
constexpr explicit operator bool() const noexcept;
// modifiers
constexpr pointer release() noexcept;
constexpr void reset(pointer p = pointer()) noexcept;
constexpr void swap(unique_ptr& u) noexcept;
// disable copy from lvalue
unique_ptr(const unique_ptr&) = delete;
unique_ptr& operator=(const unique_ptr&) = delete;
};
template<class T, class D>
class unique_ptr<T[], D>
{
public:
using pointer = /* see description */;
using element_type = T;
using deleter_type = D;
// constructors
constexpr unique_ptr() noexcept;
template<class U>
constexpr explicit unique_ptr(U p) noexcept;
template<class U>
constexpr unique_ptr(U p, /* see description */ d) noexcept;
template<class U>
constexpr unique_ptr(U p, /* see description */ d) noexcept;
constexpr unique_ptr(unique_ptr&& u) noexcept;
template<class U, class E>
constexpr unique_ptr(unique_ptr<U, E>&& u) noexcept;
constexpr unique_ptr(nullptr_t) noexcept;
// destructor
constexpr ~unique_ptr();
// assignment
constexpr unique_ptr& operator=(unique_ptr&& u) noexcept;
template<class U, class E>
constexpr unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
constexpr unique_ptr& operator=(nullptr_t) noexcept;
// observers
constexpr T& operator[](size_t i) const;
constexpr pointer get() const noexcept;
constexpr deleter_type& get_deleter() noexcept;
constexpr const deleter_type& get_deleter() const noexcept;
constexpr explicit operator bool() const noexcept;
// modifiers
constexpr pointer release() noexcept;
template<class U>
constexpr void reset(U p) noexcept;
constexpr void reset(nullptr_t = nullptr) noexcept;
constexpr void swap(unique_ptr& u) noexcept;
// disable copy from lvalue
unique_ptr(const unique_ptr&) = delete;
unique_ptr& operator=(const unique_ptr&) = delete;
};
}
Класс std::bad_weak_ptr
namespace std {
class bad_weak_ptr : public exception
{
public:
// for the specification of the special member functions
constexpr const char* what() const noexcept override;
};
}
Шаблон класса std::shared_ptr
namespace std {
template<class T>
class shared_ptr
{
public:
using element_type = remove_extent_t<T>;
using weak_type = weak_ptr<T>;
// constructors
constexpr shared_ptr() noexcept;
constexpr shared_ptr(nullptr_t) noexcept
: shared_ptr()
{
}
template<class Y>
constexpr explicit shared_ptr(Y* p);
template<class Y, class D>
constexpr shared_ptr(Y* p, D d);
template<class Y, class D, class A>
constexpr shared_ptr(Y* p, D d, A a);
template<class D>
constexpr shared_ptr(nullptr_t p, D d);
template<class D, class A>
constexpr shared_ptr(nullptr_t p, D d, A a);
template<class Y>
constexpr shared_ptr(const shared_ptr<Y>& r, element_type* p) noexcept;
template<class Y>
constexpr shared_ptr(shared_ptr<Y>&& r, element_type* p) noexcept;
constexpr shared_ptr(const shared_ptr& r) noexcept;
template<class Y>
constexpr shared_ptr(const shared_ptr<Y>& r) noexcept;
constexpr shared_ptr(shared_ptr&& r) noexcept;
template<class Y>
constexpr shared_ptr(shared_ptr<Y>&& r) noexcept;
template<class Y>
constexpr explicit shared_ptr(const weak_ptr<Y>& r);
template<class Y, class D>
constexpr shared_ptr(unique_ptr<Y, D>&& r);
// destructor
constexpr ~shared_ptr();
// assignment
constexpr shared_ptr& operator=(const shared_ptr& r) noexcept;
template<class Y>
constexpr shared_ptr& operator=(const shared_ptr<Y>& r) noexcept;
constexpr shared_ptr& operator=(shared_ptr&& r) noexcept;
template<class Y>
constexpr shared_ptr& operator=(shared_ptr<Y>&& r) noexcept;
template<class Y, class D>
constexpr shared_ptr& operator=(unique_ptr<Y, D>&& r);
// modifiers
constexpr void swap(shared_ptr& r) noexcept;
constexpr void reset() noexcept;
template<class Y>
constexpr void reset(Y* p);
template<class Y, class D>
constexpr void reset(Y* p, D d);
template<class Y, class D, class A>
constexpr void reset(Y* p, D d, A a);
// observers
constexpr element_type* get() const noexcept;
constexpr T& operator*() const noexcept;
constexpr T* operator->() const noexcept;
constexpr element_type& operator[](ptrdiff_t i) const;
constexpr long use_count() const noexcept;
constexpr explicit operator bool() const noexcept;
template<class U>
constexpr bool owner_before(const shared_ptr<U>& b) const noexcept;
template<class U>
constexpr bool owner_before(const weak_ptr<U>& b) const noexcept;
size_t owner_hash() const noexcept;
template<class U>
constexpr bool owner_equal(const shared_ptr<U>& b) const noexcept;
template<class U>
constexpr bool owner_equal(const weak_ptr<U>& b) const noexcept;
};
template<class T>
shared_ptr(weak_ptr<T>) -> shared_ptr<T>;
template<class T, class D>
shared_ptr(unique_ptr<T, D>) -> shared_ptr<T>;
}
Шаблон класса std::weak_ptr
namespace std {
template<class T>
class weak_ptr
{
public:
using element_type = remove_extent_t<T>;
// constructors
constexpr weak_ptr() noexcept;
template<class Y>
constexpr weak_ptr(const shared_ptr<Y>& r) noexcept;
constexpr weak_ptr(const weak_ptr& r) noexcept;
template<class Y>
constexpr weak_ptr(const weak_ptr<Y>& r) noexcept;
constexpr weak_ptr(weak_ptr&& r) noexcept;
template<class Y>
constexpr weak_ptr(weak_ptr<Y>&& r) noexcept;
// destructor
constexpr ~weak_ptr();
// assignment
constexpr weak_ptr& operator=(const weak_ptr& r) noexcept;
template<class Y>
constexpr weak_ptr& operator=(const weak_ptr<Y>& r) noexcept;
template<class Y>
constexpr weak_ptr& operator=(const shared_ptr<Y>& r) noexcept;
constexpr weak_ptr& operator=(weak_ptr&& r) noexcept;
template<class Y>
constexpr weak_ptr& operator=(weak_ptr<Y>&& r) noexcept;
// modifiers
constexpr void swap(weak_ptr& r) noexcept;
constexpr void reset() noexcept;
// observers
constexpr long use_count() const noexcept;
constexpr bool expired() const noexcept;
constexpr shared_ptr<T> lock() const noexcept;
template<class U>
constexpr bool owner_before(const shared_ptr<U>& b) const noexcept;
template<class U>
constexpr bool owner_before(const weak_ptr<U>& b) const noexcept;
size_t owner_hash() const noexcept;
template<class U>
constexpr bool owner_equal(const shared_ptr<U>& b) const noexcept;
template<class U>
constexpr bool owner_equal(const weak_ptr<U>& b) const noexcept;
};
template<class T>
weak_ptr(shared_ptr<T>) -> weak_ptr<T>;
}
Шаблон класса std::owner_less
namespace std {
template<class T = void>
struct owner_less;
template<class T>
struct owner_less<shared_ptr<T>>
{
constexpr bool operator()(const shared_ptr<T>&,
const shared_ptr<T>&) const noexcept;
constexpr bool operator()(const shared_ptr<T>&,
const weak_ptr<T>&) const noexcept;
constexpr bool operator()(const weak_ptr<T>&,
const shared_ptr<T>&) const noexcept;
};
template<class T>
struct owner_less<weak_ptr<T>>
{
constexpr bool operator()(const weak_ptr<T>&,
const weak_ptr<T>&) const noexcept;
constexpr bool operator()(const shared_ptr<T>&,
const weak_ptr<T>&) const noexcept;
constexpr bool operator()(const weak_ptr<T>&,
const shared_ptr<T>&) const noexcept;
};
template<>
struct owner_less<void>
{
template<class T, class U>
constexpr bool operator()(const shared_ptr<T>&,
const shared_ptr<U>&) const noexcept;
template<class T, class U>
constexpr bool operator()(const shared_ptr<T>&,
const weak_ptr<U>&) const noexcept;
template<class T, class U>
constexpr bool operator()(const weak_ptr<T>&,
const shared_ptr<U>&) const noexcept;
template<class T, class U>
constexpr bool operator()(const weak_ptr<T>&,
const weak_ptr<U>&) const noexcept;
using is_transparent = /* unspecified */;
};
}
Класс std::owner_hash
namespace std {
struct owner_hash
{
template<class T>
size_t operator()(const shared_ptr<T>&) const noexcept;
template<class T>
size_t operator()(const weak_ptr<T>&) const noexcept;
using is_transparent = /* unspecified */;
};
}
Класс std::owner_equal
namespace std {
struct owner_equal
{
template<class T, class U>
constexpr bool operator()(const shared_ptr<T>&,
const shared_ptr<U>&) const noexcept;
template<class T, class U>
constexpr bool operator()(const shared_ptr<T>&,
const weak_ptr<U>&) const noexcept;
template<class T, class U>
constexpr bool operator()(const weak_ptr<T>&,
const shared_ptr<U>&) const noexcept;
template<class T, class U>
constexpr bool operator()(const weak_ptr<T>&,
const weak_ptr<U>&) const noexcept;
using is_transparent = /* unspecified */;
};
}
Шаблон класса std::enable_shared_from_this
namespace std {
template<class T>
class enable_shared_from_this
{
protected:
constexpr enable_shared_from_this() noexcept;
constexpr enable_shared_from_this(const enable_shared_from_this&) noexcept;
constexpr enable_shared_from_this&
operator=(const enable_shared_from_this&) noexcept;
constexpr ~enable_shared_from_this();
public:
constexpr shared_ptr<T> shared_from_this();
constexpr shared_ptr<T const> shared_from_this() const;
constexpr weak_ptr<T> weak_from_this() noexcept;
constexpr weak_ptr<T const> weak_from_this() const noexcept;
private:
mutable weak_ptr<T> /*weak-this*/; // exposition-only
};
}
Специализация шаблона класса std::atomic для std::shared_ptr
namespace std {
template<class T> struct atomic<shared_ptr<T>> {
using value_type = shared_ptr<T>;
static constexpr bool is_always_lock_free = /* implementation-defined */;
bool is_lock_free() const noexcept;
constexpr atomic() noexcept = default;
constexpr atomic(nullptr_t) noexcept : atomic() {}
constexpr atomic(shared_ptr<T> desired) noexcept;
atomic(const atomic&) = delete;
void operator=(const atomic&) = delete;
constexpr shared_ptr<T>
load(memory_order order = memory_order::seq_cst) const noexcept;
constexpr operator shared_ptr<T>() const noexcept;
constexpr void store(shared_ptr<T> desired,
memory_order order = memory_order::seq_cst) noexcept;
constexpr void operator=(shared_ptr<T> desired) noexcept;
constexpr void operator=(nullptr_t) noexcept;
constexpr shared_ptr<T>
exchange(shared_ptr<T> desired,
memory_order order = memory_order::seq_cst) noexcept;
constexpr bool
compare_exchange_weak(shared_ptr<T>& expected, shared_ptr<T> desired,
memory_order success, memory_order failure) noexcept;
constexpr bool
compare_exchange_strong(shared_ptr<T>& expected, shared_ptr<T> desired,
memory_order success, memory_order failure) noexcept;
constexpr bool
compare_exchange_weak(shared_ptr<T>& expected, shared_ptr<T> desired,
memory_order order = memory_order::seq_cst) noexcept;
constexpr bool
compare_exchange_strong(shared_ptr<T>& expected, shared_ptr<T> desired,
memory_order order = memory_order::seq_cst) noexcept;
constexpr void wait(shared_ptr<T> old,
memory_order order = memory_order::seq_cst) const noexcept;
constexpr void notify_one() noexcept;
constexpr void notify_all() noexcept;
private:
shared_ptr<T> p; // exposition only
};
}
Специализация шаблона класса std::atomic для std::weak_ptr
namespace std {
template<class T> struct atomic<weak_ptr<T>> {
using value_type = weak_ptr<T>;
static constexpr bool is_always_lock_free = /* implementation-defined */;
bool is_lock_free() const noexcept;
constexpr atomic() noexcept = default;
constexpr atomic(weak_ptr<T> desired) noexcept;
atomic(const atomic&) = delete;
void operator=(const atomic&) = delete;
constexpr weak_ptr<T>
load(memory_order order = memory_order::seq_cst) const noexcept;
constexpr operator weak_ptr<T>() const noexcept;
constexpr void store(weak_ptr<T> desired,
memory_order order = memory_order::seq_cst) noexcept;
constexpr void operator=(weak_ptr<T> desired) noexcept;
constexpr weak_ptr<T>
exchange(weak_ptr<T> desired,
memory_order order = memory_order::seq_cst) noexcept;
constexpr bool
compare_exchange_weak(weak_ptr<T>& expected, shared_ptr<T> desired,
memory_order success, memory_order failure) noexcept;
constexpr bool
compare_exchange_strong(weak_ptr<T>& expected, shared_ptr<T> desired,
memory_order success, memory_order failure) noexcept;
constexpr bool
compare_exchange_weak(weak_ptr<T>& expected, shared_ptr<T> desired,
memory_order order = memory_order::seq_cst) noexcept;
constexpr bool
compare_exchange_strong(weak_ptr<T>& expected, shared_ptr<T> desired,
memory_order order = memory_order::seq_cst) noexcept;
constexpr void wait(weak_ptr<T> old,
memory_order order = memory_order::seq_cst) const noexcept;
constexpr void notify_one() noexcept;
constexpr void notify_all() noexcept;
private:
weak_ptr<T> p; // exposition only
};
}
Шаблон класса std::out_ptr_t
namespace std {
template<class Smart, class Pointer, class... Args>
class out_ptr_t
{
public:
constexpr explicit out_ptr_t(Smart&, Args...);
out_ptr_t(const out_ptr_t&) = delete;
constexpr ~out_ptr_t();
constexpr operator Pointer*() const noexcept;
operator void**() const noexcept;
private:
Smart& s; // exposition-only
tuple<Args...> a; // exposition-only
Pointer p; // exposition-only
};
}
Шаблон класса std::inout_ptr_t
namespace std {
template<class Smart, class Pointer, class... Args>
class inout_ptr_t
{
public:
constexpr explicit inout_ptr_t(Smart&, Args...);
inout_ptr_t(const inout_ptr_t&) = delete;
constexpr ~inout_ptr_t();
constexpr operator Pointer*() const noexcept;
operator void**() const noexcept;
private:
Smart& s; // exposition-only
tuple<Args...> a; // exposition-only
Pointer p; // exposition-only
};
}
Шаблон класса std::indirect
namespace std {
template<class T, class Allocator = allocator<T>>
class indirect
{
public:
using value_type = T;
using allocator_type = Allocator;
using pointer = typename allocator_traits<Allocator>::pointer;
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
// constructors
constexpr explicit indirect();
constexpr explicit indirect(allocator_arg_t, const Allocator& a);
constexpr indirect(const indirect& other);
constexpr indirect(allocator_arg_t, const Allocator& a, const indirect& other);
constexpr indirect(indirect&& other) noexcept;
constexpr indirect(allocator_arg_t,
const Allocator& a,
indirect&& other) noexcept(/* see description */);
template<class U = T>
constexpr explicit indirect(U&& u);
template<class U = T>
constexpr explicit indirect(allocator_arg_t, const Allocator& a, U&& u);
template<class... Us>
constexpr explicit indirect(in_place_t, Us&&... us);
template<class... Us>
constexpr explicit indirect(allocator_arg_t,
const Allocator& a,
in_place_t,
Us&&... us);
template<class I, class... Us>
constexpr explicit indirect(in_place_t, initializer_list<I> ilist, Us&&... us);
template<class I, class... Us>
constexpr explicit indirect(allocator_arg_t,
const Allocator& a,
in_place_t,
initializer_list<I> ilist,
Us&&... us);
// destructor
constexpr ~indirect();
// assignment
constexpr indirect& operator=(const indirect& other);
constexpr indirect& operator=(indirect&& other) noexcept(/* see description */);
template<class U = T>
constexpr indirect& operator=(U&& u);
// observers
constexpr const T& operator*() const& noexcept;
constexpr T& operator*() & noexcept;
constexpr const T&& operator*() const&& noexcept;
constexpr T&& operator*() && noexcept;
constexpr const_pointer operator->() const noexcept;
constexpr pointer operator->() noexcept;
constexpr bool valueless_after_move() const noexcept;
constexpr allocator_type get_allocator() const noexcept;
// swap
constexpr void swap(indirect& other) noexcept(/* see description */);
friend constexpr void swap(indirect& lhs,
indirect& rhs) noexcept(/* see description */);
// relational operators
template<class U, class AA>
friend constexpr bool operator==(
const indirect& lhs,
const indirect<U, AA>& rhs) noexcept(/* see description */);
template<class U, class AA>
friend constexpr auto operator<=>(const indirect& lhs, const indirect<U, AA>& rhs)
-> /*synth-three-way-result*/<T, U>;
// comparison with T
template<class U>
friend constexpr bool operator==(const indirect& lhs,
const U& rhs) noexcept(/* see description */);
template<class U>
friend constexpr auto operator<=>(const indirect& lhs, const U& rhs)
-> /*synth-three-way-result*/<T, U>;
private:
pointer /*p*/; // exposition-only
Allocator /*alloc*/ = Allocator(); // exposition-only
};
template<class Value>
indirect(Value) -> indirect<Value>;
template<class Allocator, class Value>
indirect(allocator_arg_t, Allocator, Value)
-> indirect<Value,
typename allocator_traits<Allocator>::template rebind_alloc<Value>>;
}
Шаблон класса std::polymorphic
namespace std {
template<class T, class Allocator = allocator<T>>
class polymorphic
{
public:
using value_type = T;
using allocator_type = Allocator;
using pointer = typename allocator_traits<Allocator>::pointer;
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
// constructors
constexpr explicit polymorphic();
constexpr explicit polymorphic(allocator_arg_t, const Allocator& a);
constexpr polymorphic(const polymorphic& other);
constexpr polymorphic(allocator_arg_t, const Allocator& a, const polymorphic& other);
constexpr polymorphic(polymorphic&& other) noexcept;
constexpr polymorphic(allocator_arg_t,
const Allocator& a,
polymorphic&& other) noexcept(/* see description */);
template<class U = T>
constexpr explicit polymorphic(U&& u);
template<class U = T>
constexpr explicit polymorphic(allocator_arg_t, const Allocator& a, U&& u);
template<class U, class... Ts>
constexpr explicit polymorphic(in_place_type_t<U>, Ts&&... ts);
template<class U, class... Ts>
constexpr explicit polymorphic(allocator_arg_t,
const Allocator& a,
in_place_type_t<U>,
Ts&&... ts);
template<class U, class I, class... Us>
constexpr explicit polymorphic(in_place_type_t<U>,
initializer_list<I> ilist,
Us&&... us);
template<class U, class I, class... Us>
constexpr explicit polymorphic(allocator_arg_t,
const Allocator& a,
in_place_type_t<U>,
initializer_list<I> ilist,
Us&&... us);
// destructor
constexpr ~polymorphic();
// assignment
constexpr polymorphic& operator=(const polymorphic& other);
constexpr polymorphic& operator=(polymorphic&& other) noexcept(/* see description */);
// observers
constexpr const T& operator*() const noexcept;
constexpr T& operator*() noexcept;
constexpr const_pointer operator->() const noexcept;
constexpr pointer operator->() noexcept;
constexpr bool valueless_after_move() const noexcept;
constexpr allocator_type get_allocator() const noexcept;
// swap
constexpr void swap(polymorphic& other) noexcept(/* see description */);
friend constexpr void swap(polymorphic& lhs,
polymorphic& rhs) noexcept(/* see description */);
private:
Allocator /*alloc*/ = Allocator(); // exposition-only
};
}
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/header/memory