Standard library header <memory>
From cppreference.net
이 헤더는 동적 메모리 관리 라이브러리의 일부입니다.
포함 항목 |
|
|
(C++20)
|
3방향 비교 연산자 지원 |
클래스 |
|
포인터 특성 |
|
|
(C++11)
|
포인터와 유사한 타입에 대한 정보를 제공함
(클래스 템플릿) |
가비지 컬렉터 지원 |
|
|
(C++11)
(removed in C++23)
|
포인터 안전성 모델들을 나열함
(enum) |
할당자 |
|
|
기본 할당자
(클래스 템플릿) |
|
|
(C++11)
|
할당자 타입에 대한 정보를 제공합니다
(클래스 템플릿) |
|
(C++23)
|
allocate_at_least
에 의해 할당된 저장 공간의 주소와 실제 크기를 기록합니다
(클래스 템플릿) |
|
(C++11)
|
지정된 타입이 uses-allocator construction을 지원하는지 확인합니다
(클래스 템플릿) |
초기화되지 않은 저장소 |
|
|
(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)
|
값(value) 의미론을 가지는 동적으로 할당된 객체를 포함하는 다형적 래퍼
(클래스 템플릿) |
헬퍼 클래스 |
|
|
(C++20)
|
원자적 공유 포인터
(클래스 템플릿 특수화) |
|
(C++20)
|
원자적 약한 포인터
(클래스 템플릿 특수화) |
|
(C++11)
|
shared 및 weak 포인터의 혼합 타입 소유자 기반 순서 지정을 제공합니다
(클래스 템플릿) |
|
(C++26)
|
shared 및 weak 포인터를 위한 소유자 기반 해싱을 제공합니다
(클래스) |
|
(C++26)
|
shared 및 weak 포인터의 혼합 타입 소유자 기반 동등 비교를 제공함
(클래스) |
|
(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)
|
bool, 정수형,
부동소수점,
(since C++20)
및 포인터 타입에 대한 atomic 클래스 템플릿과 특수화
(클래스 템플릿) |
태그 |
|
|
(C++11)
|
할당자 인식 생성자를 선택하는 데 사용되는 태그
(태그) |
함수 |
|
Uses-allocator construction |
|
|
(C++20)
|
주어진 타입에 필요한 uses-allocator construction 방식에 맞는 인수 목록을 준비합니다
(함수 템플릿) |
|
(C++20)
|
uses-allocator 구성을 통해 주어진 타입의 객체를 생성합니다
(함수 템플릿) |
|
지정된 메모리 위치에서 uses-allocator construction을 통해 주어진 타입의 객체를 생성합니다
(함수 템플릿) |
|
기타 |
|
|
(C++20)
|
포인터와 유사한 타입으로부터 원시 포인터를 얻음
(함수 템플릿) |
|
(C++11)
|
객체의 실제 주소를 획득하며,
&
연산자가 오버로드된 경우에도 동작함
(함수 템플릿) |
|
(C++11)
|
버퍼에서 포인터를 정렬합니다
(함수) |
|
(C++20)
|
컴파일러에게 포인터가 정렬되어 있음을 알림
(함수 템플릿) |
|
(C++26)
|
포인터가 주어진 값 이상의 정렬을 가진 객체를 가리키는지 여부를 검사합니다
(함수 템플릿) |
명시적 수명 관리 |
|
|
주어진 저장 공간에서 객체 표현을 재사용하여 객체를 암시적으로 생성합니다
(함수 템플릿) |
|
가비지 컬렉터 지원 |
|
|
(C++11)
(C++23에서 제거됨)
|
객체가 회수되지 않도록 선언합니다
(함수) |
|
(C++11)
(removed in C++23)
|
객체가 재활용될 수 있음을 선언합니다
(function template) |
|
(C++11)
(C++23에서 제거됨)
|
메모리 영역에 추적 가능한 포인터가 포함되어 있지 않음을 선언합니다
(함수) |
|
(C++11)
(C++23에서 제거됨)
|
std::declare_no_pointers
의 효과를 취소함
(함수) |
|
(C++11)
(removed in C++23)
|
현재 포인터 안전성 모델을 반환합니다
(함수) |
초기화되지 않은 저장소 |
|
|
객체 범위를 초기화되지 않은 메모리 영역으로 복사합니다
(함수 템플릿) |
|
|
(C++11)
|
객체들을 지정된 개수만큼 초기화되지 않은 메모리 영역에 복사합니다
(함수 템플릿) |
|
범위로 정의된 초기화되지 않은 메모리 영역에 객체를 복사합니다
(function template) |
|
|
시작점과 개수로 정의된 초기화되지 않은 메모리 영역에 객체를 복사합니다
(함수 템플릿) |
|
|
(C++17)
|
객체 범위를 초기화되지 않은 메모리 영역으로 이동
(함수 템플릿) |
|
(C++17)
|
여러 객체를 초기화되지 않은 메모리 영역으로 이동
(함수 템플릿) |
|
(C++17)
|
초기화되지 않은 메모리 영역에서
기본 초기화
를 통해 객체를 생성합니다. 범위로 정의된 영역에 적용됩니다.
(함수 템플릿) |
|
시작점과 개수로 정의된 초기화되지 않은 메모리 영역에서
기본 초기화
를 통해 객체를 생성합니다
(함수 템플릿) |
|
|
(C++17)
|
초기화되지 않은 메모리 영역에서
값 초기화
를 통해 객체를 생성합니다. 범위로 정의된 영역에 적용됩니다.
(함수 템플릿) |
|
(C++17)
|
시작점과 개수로 정의된 초기화되지 않은 메모리 영역에서
값 초기화
를 통해 객체를 생성합니다
(함수 템플릿) |
|
(C++20)
|
주어진 주소에 객체를 생성합니다
(함수 템플릿) |
|
(C++17)
|
주어진 주소의 객체를 파괴합니다
(함수 템플릿) |
|
(C++17)
|
객체 범위를 파괴합니다
(함수 템플릿) |
|
(C++17)
|
범위 내의 여러 객체를 파괴합니다
(함수 템플릿) |
|
(C++17에서 사용 중단됨)
(C++20에서 제거됨)
|
초기화되지 않은 저장 공간을 획득
(함수 템플릿) |
|
(C++17에서 사용 중단됨)
(C++20에서 제거됨)
|
초기화되지 않은 저장소를 해제합니다
(함수 템플릿) |
스마트 포인터 비멤버 연산 |
|
|
(C++14)
(C++20)
|
새로운 객체를 관리하는 unique pointer를 생성합니다
(함수 템플릿) |
|
(C++20에서 제거됨)
(C++20)
|
다른
unique_ptr
또는
nullptr
와 비교
(함수 템플릿) |
|
새로운 객체를 관리하는 shared pointer를 생성합니다
(함수 템플릿) |
|
|
할당자를 사용하여 할당된 새 객체를 관리하는 shared_ptr을 생성합니다
(함수 템플릿) |
|
|
저장된 포인터에
static_cast
,
dynamic_cast
,
const_cast
, 또는
reinterpret_cast
를 적용합니다
(함수 템플릿) |
|
|
지정된 타입의 삭제자를 반환합니다 (소유하고 있는 경우)
(function template) |
|
|
(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
생성
(함수 템플릿) |
std::shared_ptr
에 대한 원자적 연산을 특수화합니다
(함수 템플릿) |
함수형 객체 |
|
|
네임스페이스에 정의됨
std::ranges
|
|
초기화되지 않은 저장소 |
|
|
(C++20)
|
객체 범위를 초기화되지 않은 메모리 영역에 복사합니다
(알고리즘 함수 객체) |
|
(C++20)
|
여러 객체를 초기화되지 않은 메모리 영역에 복사합니다
(알고리즘 함수 객체) |
|
(C++20)
|
객체를 범위로 정의된 초기화되지 않은 메모리 영역에 복사합니다
(알고리즘 함수 객체) |
|
(C++20)
|
객체를 시작점과 개수로 정의된 초기화되지 않은 메모리 영역에 복사합니다
(알고리즘 함수 객체) |
|
(C++20)
|
객체 범위를 초기화되지 않은 메모리 영역으로 이동합니다
(알고리즘 함수 객체) |
|
(C++20)
|
여러 객체를 초기화되지 않은 메모리 영역으로 이동합니다
(알고리즘 함수 객체) |
|
범위로 정의된 초기화되지 않은 메모리 영역에서
기본 초기화
로 객체를 생성합니다
(알고리즘 함수 객체) |
|
|
시작점과 개수로 정의된 초기화되지 않은 메모리 영역에서
기본 초기화
로 객체를 생성합니다
(알고리즘 함수 객체) |
|
|
범위로 정의된 초기화되지 않은 메모리 영역에서
값 초기화
로 객체를 생성합니다
(알고리즘 함수 객체) |
|
|
시작점과 개수로 정의된 초기화되지 않은 메모리 영역에서
값 초기화
로 객체를 생성합니다
(알고리즘 함수 객체) |
|
|
(C++20)
|
주어진 주소에 객체를 생성합니다
(알고리즘 함수 객체) |
|
(C++20)
|
주어진 주소의 객체를 파괴합니다
(알고리즘 함수 객체) |
|
(C++20)
|
객체 범위를 파괴합니다
(알고리즘 함수 객체) |
|
(C++20)
|
범위 내의 여러 객체를 파괴합니다
(알고리즘 함수 객체) |
시놉시스
#include <compare> namespace std { // pointer Traits template<class Ptr> struct pointer_traits; // 독립 실행 환경 template<class T> struct pointer_traits<T*>; // 독립 실행 환경 // 포인터 변환 template<class T> constexpr T* to_address(T* p) noexcept; // 독립 실행 환경 template<class Ptr> constexpr auto to_address(const Ptr& p) noexcept; // 독립 실행 환경 // 포인터 정렬 void* align(size_t alignment, size_t size, void*& ptr, size_t& space); // 독립 실행 환경 template<size_t N, class T> constexpr T* assume_aligned(T* ptr); // 독립 실행 환경 template<size_t Alignment, class T> bool is_sufficiently_aligned(T* ptr); // 명시적 수명 관리 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; // 독립 실행 환경 template<class T> const volatile T* start_lifetime_as(const volatile void* p) noexcept; // 독립형 환경 template<class T> T* start_lifetime_as_array(void* p, size_t n) noexcept; // 독립 실행 환경 template<class T> const T* start_lifetime_as_array(const void* p, size_t n) noexcept; // 독립 실행 환경 template<class T> volatile T* start_lifetime_as_array(volatile void* p, size_t n) noexcept; // 독립 실행 환경 template<class T> const volatile T* start_lifetime_as_array(const volatile void* p, // 독립 실행 환경 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); // 독립 실행 환경 // allocator argument tag struct allocator_arg_t { explicit allocator_arg_t() = default; }; // 독립 실행 환경 inline constexpr allocator_arg_t allocator_arg{}; // 독립 실행 환경 // uses_allocator template<class T, class Alloc> struct uses_allocator; // 독립 실행 환경 // uses_allocator template<class T, class Alloc> constexpr bool uses_allocator_v = uses_allocator<T, Alloc>::value; // 독립 실행 환경 // uses-allocator construction template<class T, class Alloc, class... Args> constexpr auto uses_allocator_construction_args(const Alloc& alloc, // 독립형 환경 Args&&... args) noexcept; template<class T, class Alloc, class Tuple1, class Tuple2> constexpr auto uses_allocator_construction_args(const Alloc& alloc, // 독립 실행 환경 piecewise_construct_t, Tuple1&& x, Tuple2&& y) noexcept; template<class T, class Alloc> constexpr auto uses_allocator_construction_args( const Alloc& alloc) noexcept; // 독립 실행 환경 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, // 독립 실행 환경 pair<U, V>& pr) noexcept; template<class T, class Alloc, class U, class V> constexpr auto uses_allocator_construction_args(const Alloc& alloc, // 독립 실행 환경 const pair<U, V>& pr) noexcept; template<class T, class Alloc, class U, class V> constexpr auto uses_allocator_construction_args(const Alloc& alloc, // 독립 실행 환경 pair<U, V>&& pr) noexcept; template<class T, class Alloc, class U, class V> constexpr auto uses_allocator_construction_args(const Alloc& alloc, // 독립 실행 환경 const pair<U, V>&& pr) noexcept; template<class T, class Alloc, /*pair-like*/ P> constexpr auto uses_allocator_construction_args(const Alloc& alloc, // 독립 실행 환경 P&& p) noexcept; template<class T, class Alloc, class U> constexpr auto uses_allocator_construction_args(const Alloc& alloc, // 독립 실행 환경 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; }; // 기본 할당자 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; // 독립 실행 환경 // 특수화된 알고리즘 // 특수 메모리 개념 template<class I> concept no-throw-input-iterator = /* 설명 참조 */; // exposition-only template<class I> concept no-throw-forward-iterator = /* 설명 참조 */; // exposition-only template<class S, class I> concept no-throw-sentinel-for = /* 설명 참조 */; // exposition-only template<class R> concept no-throw-input-range = /* 설명 참조 */; // exposition-only template<class R> concept no-throw-forward-range = /* 설명 참조 */; // exposition-only template<class NoThrowForwardIter> constexpr void uninitialized_default_construct(NoThrowForwardIter first, // 독립 실행 환경 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<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); // 독립 실행 환경 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<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>; // 독립 실행 환경 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); // 독립 실행 환경 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); // 독립 실행 환경 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<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, // 독립 실행 환경 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>; // 독립 실행 환경 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); // 독립 실행 환경 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, // 독립 실행 환경 O ofirst, S olast); } template<class NoThrowForwardIter, class T> constexpr void uninitialized_fill(NoThrowForwardIter first, // 독립 실행 환경 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); // 독립 실행 환경 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); // 독립 실행 환경 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, // 독립 실행 환경 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); // 독립 실행 환경 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, // 독립 실행 환경 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; // 독립형 환경 template<no-throw-input-iterator I> requires destructible<iter_value_t<I>> constexpr I destroy_n(I first, iter_difference_t<I> n) noexcept; // 독립 실행 환경 } // 클래스 템플릿 unique_ptr template<class T> struct default_delete; // 독립 실행 환경 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>; // 독립 실행 환경 template<class T, class... Args> constexpr unique_ptr<T> make_unique(Args&&... args); // T는 배열이 아님 template<class T> constexpr unique_ptr<T> make_unique(size_t n); // T는 U[]입니다 template<class T, class... Args> /* 지정되지 않음 */ make_unique(Args&&...) = delete; // T는 U[N]입니다 template<class T> constexpr unique_ptr<T> make_unique_for_overwrite(); // T는 배열이 아님 template<class T> constexpr unique_ptr<T> make_unique_for_overwrite(size_t n); // T는 U[]입니다 template<class T, class... Args> /* 미지정 */ make_unique_for_overwrite(Args&&...) = delete; // T는 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> bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); // freestanding template<class T1, class D1, class T2, class D2> bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); // 독립 실행 환경 template<class T1, class D1, class T2, class D2> bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); // 독립 실행 환경 template<class T1, class D1, class T2, class D2> bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); // 독립 실행 환경 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> 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); // 독립 실행 환경 template<class T, class D> constexpr bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept; // 독립 실행 환경 template<class T, class D> constexpr bool operator<(const unique_ptr<T, D>& x, nullptr_t); // 독립 실행 환경 template<class T, class D> constexpr bool operator<(nullptr_t, const unique_ptr<T, D>& y); // 독립 실행 환경 template<class T, class D> constexpr bool operator>(const unique_ptr<T, D>& x, nullptr_t); // 독립 실행 환경 template<class T, class D> constexpr bool operator>(nullptr_t, const unique_ptr<T, D>& y); // 독립 실행 환경 template<class T, class D> constexpr bool operator<=(const unique_ptr<T, D>& x, nullptr_t); // 독립 실행 환경 template<class T, class D> constexpr bool operator<=(nullptr_t, const unique_ptr<T, D>& y); // 독립 실행 환경 template<class T, class D> constexpr bool operator>=(const unique_ptr<T, D>& x, nullptr_t); // 독립 실행 환경 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 생성 template<class T, class... Args> shared_ptr<T> make_shared(Args&&... args); // T는 배열이 아님 template<class T, class A, class... Args> shared_ptr<T> allocate_shared(const A& a, Args&&... args); // T는 배열이 아님 template<class T> shared_ptr<T> make_shared(size_t N); // T는 U[]입니다 template<class T, class A> shared_ptr<T> allocate_shared(const A& a, size_t N); // T는 U[]입니다 template<class T> shared_ptr<T> make_shared(); // T는 U[N]입니다 template<class T, class A> shared_ptr<T> allocate_shared(const A& a); // T는 U[N]입니다 template<class T> shared_ptr<T> make_shared(size_t N, const remove_extent_t<T>& u); // T는 U[]입니다 template<class T, class A> shared_ptr<T> allocate_shared(const A& a, size_t N, const remove_extent_t<T>& u); // T는 U[]입니다 template<class T> shared_ptr<T> make_shared(const remove_extent_t<T>& u); // T는 U[N]입니다 template<class T, class A> shared_ptr<T> allocate_shared(const A& a, const remove_extent_t<T>& u); // T는 U[N]입니다 template<class T> shared_ptr<T> make_shared_for_overwrite(); // T는 U[]가 아님 template<class T, class A> shared_ptr<T> allocate_shared_for_overwrite(const A& a); // T는 U[]가 아님 template<class T> shared_ptr<T> make_shared_for_overwrite(size_t N); // T는 U[]입니다 template<class T, class A> shared_ptr<T> allocate_shared_for_overwrite(const A& a, size_t N); // T는 U[]입니다 // shared_ptr 비교 연산 template<class T, class U> bool operator==(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept; template<class T, class U> strong_ordering operator<=>(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept; template<class T> bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept; template<class T> strong_ordering operator<=>(const shared_ptr<T>& x, nullptr_t) noexcept; // shared_ptr 전용 알고리즘 template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept; // shared_ptr 캐스트 template<class T, class U> shared_ptr<T> static_pointer_cast(const shared_ptr<U>& r) noexcept; template<class T, class U> shared_ptr<T> static_pointer_cast(shared_ptr<U>&& r) noexcept; template<class T, class U> shared_ptr<T> dynamic_pointer_cast(const shared_ptr<U>& r) noexcept; template<class T, class U> shared_ptr<T> dynamic_pointer_cast(shared_ptr<U>&& r) noexcept; template<class T, class U> shared_ptr<T> const_pointer_cast(const shared_ptr<U>& r) noexcept; template<class T, class U> 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> 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 전용 알고리즘 template<class T> 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; // 해시 지원 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 // 함수 템플릿 out_ptr template<class Pointer = void, class Smart, class... Args> auto out_ptr(Smart& s, Args&&... args); // freestanding // 클래스 템플릿 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> auto inout_ptr(Smart& s, Args&&... args); // freestanding // 클래스 템플릿 indirect template<class T, class Allocator = allocator<T>> class indirect; // 해시 지원 template<class T, class Alloc> struct hash<indirect<T, Alloc>>; // 클래스 템플릿 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>>; } }
헬퍼 개념
참고: 이러한 이름들 은 설명 전용이며, 인터페이스의 일부가 아닙니다.
template<class I> concept no-throw-input-iterator = // 설명 전용 input_iterator<I> && is_lvalue_reference_v<iter_reference_t<I>> && same_as<remove_cvref_t<iter_reference_t<I>>, iter_value_t<I>>; template<class S, class I> concept no-throw-sentinel-for = sentinel_for<S, I>; // 설명 전용 template<class R> concept no-throw-input-range = // 설명 전용 ranges::range<R> && no-throw-input-iterator<ranges::iterator_t<R>> && no-throw-sentinel-for<ranges::sentinel_t<R>, ranges::iterator_t<R>>; template<class I> concept no-throw-forward-iterator = // 설명 전용 no-throw-input-iterator<I> && forward_iterator<I> && no-throw-sentinel-for<I, I>; template<class R> concept no-throw-forward-range = // 설명 전용 no-throw-input-range<R> && no-throw-forward-iterator<ranges::iterator_t<R>>;
클래스 템플릿 std::pointer_traits
namespace std { template<class Ptr> struct pointer_traits { /* 설명 참조 */; }; 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(/* 설명 참조 */ 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 = /* 설명 참조 */; using const_pointer = /* 설명 참조 */; using void_pointer = /* 설명 참조 */; using const_void_pointer = /* 설명 참조 */; using difference_type = /* 설명 참조 */; using size_type = /* 설명 참조 */; using propagate_on_container_copy_assignment = /* 설명 참조 */; using propagate_on_container_move_assignment = /* 설명 참조 */; using propagate_on_container_swap = /* 설명 참조 */; using is_always_equal = /* 설명 참조 */; template<class T> using rebind_alloc = /* 설명 참조 */; 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 = /* 설명 참조 */; using element_type = T; using deleter_type = D; // 생성자 constexpr unique_ptr() noexcept; constexpr explicit unique_ptr(type_identity_t<pointer> p) noexcept; constexpr unique_ptr(type_identity_t<pointer> p, /* 설명 참조 */ d1) noexcept; constexpr unique_ptr(type_identity_t<pointer> p, /* 설명 참조 */ 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; // 소멸자 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(/* 설명 참조 */); 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; // 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 = /* 설명 참조 */; using element_type = T; using deleter_type = D; // 생성자 constexpr unique_ptr() noexcept; template<class U> constexpr explicit unique_ptr(U p) noexcept; template<class U> constexpr unique_ptr(U p, /* 설명 참조 */ d) noexcept; template<class U> constexpr unique_ptr(U p, /* 설명 참조 */ 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; // 소멸자 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; // 수정자 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; // 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: // 특수 멤버 함수의 사양을 위해 const char* what() const noexcept override; }; }
namespace std { template<class T> class shared_ptr { public: using element_type = remove_extent_t<T>; using weak_type = weak_ptr<T>; // 생성자 constexpr shared_ptr() noexcept; constexpr shared_ptr(nullptr_t) noexcept : shared_ptr() { } template<class Y> explicit shared_ptr(Y* p); template<class Y, class D> shared_ptr(Y* p, D d); template<class Y, class D, class A> shared_ptr(Y* p, D d, A a); template<class D> shared_ptr(nullptr_t p, D d); template<class D, class A> shared_ptr(nullptr_t p, D d, A a); template<class Y> shared_ptr(const shared_ptr<Y>& r, element_type* p) noexcept; template<class Y> shared_ptr(shared_ptr<Y>&& r, element_type* p) noexcept; shared_ptr(const shared_ptr& r) noexcept; template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept; shared_ptr(shared_ptr&& r) noexcept; template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept; template<class Y> explicit shared_ptr(const weak_ptr<Y>& r); template<class Y, class D> shared_ptr(unique_ptr<Y, D>&& r); // 소멸자 ~shared_ptr(); // assignment shared_ptr& operator=(const shared_ptr& r) noexcept; template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r) noexcept; shared_ptr& operator=(shared_ptr&& r) noexcept; template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r) noexcept; template<class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r); // 수정자 void swap(shared_ptr& r) noexcept; void reset() noexcept; template<class Y> void reset(Y* p); template<class Y, class D> void reset(Y* p, D d); template<class Y, class D, class A> void reset(Y* p, D d, A a); // observers element_type* get() const noexcept; T& operator*() const noexcept; T* operator->() const noexcept; element_type& operator[](ptrdiff_t i) const; long use_count() const noexcept; explicit operator bool() const noexcept; template<class U> bool owner_before(const shared_ptr<U>& b) const noexcept; template<class U> bool owner_before(const weak_ptr<U>& b) const noexcept; size_t owner_hash() const noexcept; template<class U> bool owner_equal(const shared_ptr<U>& b) const noexcept; template<class U> 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>; // 생성자 constexpr weak_ptr() noexcept; template<class Y> weak_ptr(const shared_ptr<Y>& r) noexcept; weak_ptr(const weak_ptr& r) noexcept; template<class Y> weak_ptr(const weak_ptr<Y>& r) noexcept; weak_ptr(weak_ptr&& r) noexcept; template<class Y> weak_ptr(weak_ptr<Y>&& r) noexcept; // 소멸자 ~weak_ptr(); // 대입 연산 weak_ptr& operator=(const weak_ptr& r) noexcept; template<class Y> weak_ptr& operator=(const weak_ptr<Y>& r) noexcept; template<class Y> weak_ptr& operator=(const shared_ptr<Y>& r) noexcept; weak_ptr& operator=(weak_ptr&& r) noexcept; template<class Y> weak_ptr& operator=(weak_ptr<Y>&& r) noexcept; // 수정자 void swap(weak_ptr& r) noexcept; void reset() noexcept; // 관찰자 long use_count() const noexcept; bool expired() const noexcept; shared_ptr<T> lock() const noexcept; template<class U> bool owner_before(const shared_ptr<U>& b) const noexcept; template<class U> bool owner_before(const weak_ptr<U>& b) const noexcept; size_t owner_hash() const noexcept; template<class U> bool owner_equal(const shared_ptr<U>& b) const noexcept; template<class U> 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>> { bool operator()(const shared_ptr<T>&, const shared_ptr<T>&) const noexcept; bool operator()(const shared_ptr<T>&, const weak_ptr<T>&) const noexcept; bool operator()(const weak_ptr<T>&, const shared_ptr<T>&) const noexcept; }; template<class T> struct owner_less<weak_ptr<T>> { bool operator()(const weak_ptr<T>&, const weak_ptr<T>&) const noexcept; bool operator()(const shared_ptr<T>&, const weak_ptr<T>&) const noexcept; bool operator()(const weak_ptr<T>&, const shared_ptr<T>&) const noexcept; }; template<> struct owner_less<void> { template<class T, class U> bool operator()(const shared_ptr<T>&, const shared_ptr<U>&) const noexcept; template<class T, class U> bool operator()(const shared_ptr<T>&, const weak_ptr<U>&) const noexcept; template<class T, class U> bool operator()(const weak_ptr<T>&, const shared_ptr<U>&) const noexcept; template<class T, class U> bool operator()(const weak_ptr<T>&, const weak_ptr<U>&) const noexcept; using is_transparent = /* 지정되지 않음 */; }; }
클래스 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 = /* 지정되지 않음 */; }; }
클래스 std::owner_equal
namespace std { struct owner_equal { template<class T, class U> bool operator()(const shared_ptr<T>&, const shared_ptr<U>&) const noexcept; template<class T, class U> bool operator()(const shared_ptr<T>&, const weak_ptr<U>&) const noexcept; template<class T, class U> bool operator()(const weak_ptr<T>&, const shared_ptr<U>&) const noexcept; template<class T, class U> bool operator()(const weak_ptr<T>&, const weak_ptr<U>&) const noexcept; using is_transparent = /* 지정되지 않음 */; }; }
namespace std { template<class T> class enable_shared_from_this { protected: constexpr enable_shared_from_this() noexcept; enable_shared_from_this(const enable_shared_from_this&) noexcept; enable_shared_from_this& operator=(const enable_shared_from_this&) noexcept; ~enable_shared_from_this(); public: shared_ptr<T> shared_from_this(); shared_ptr<T const> shared_from_this() const; weak_ptr<T> weak_from_this() noexcept; weak_ptr<T const> weak_from_this() const noexcept; private: mutable weak_ptr<T> /*weak-this*/; // 설명 전용 }; }
namespace std { template<class T> struct atomic<shared_ptr<T>> { using value_type = shared_ptr<T>; static constexpr bool is_always_lock_free = /* 구현 정의 */; bool is_lock_free() const noexcept; void store(shared_ptr<T> desired, memory_order order = memory_order::seq_cst) noexcept; shared_ptr<T> load(memory_order order = memory_order::seq_cst) const noexcept; operator shared_ptr<T>() const noexcept; shared_ptr<T> exchange(shared_ptr<T> desired, memory_order order = memory_order::seq_cst) noexcept; bool compare_exchange_weak(shared_ptr<T>& expected, shared_ptr<T> desired, memory_order success, memory_order failure) noexcept; bool compare_exchange_strong(shared_ptr<T>& expected, shared_ptr<T> desired, memory_order success, memory_order failure) noexcept; bool compare_exchange_weak(shared_ptr<T>& expected, shared_ptr<T> desired, memory_order order = memory_order::seq_cst) noexcept; bool compare_exchange_strong(shared_ptr<T>& expected, shared_ptr<T> desired, memory_order order = memory_order::seq_cst) noexcept; constexpr atomic() noexcept = default; atomic(shared_ptr<T> desired) noexcept; atomic(const atomic&) = delete; void operator=(const atomic&) = delete; void operator=(shared_ptr<T> desired) noexcept; private: shared_ptr<T> p; // 설명 전용 }; }
클래스 템플릿 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 = /* 구현 정의 */; bool is_lock_free() const noexcept; void store(weak_ptr<T> desired, memory_order order = memory_order::seq_cst) noexcept; weak_ptr<T> load(memory_order order = memory_order::seq_cst) const noexcept; operator weak_ptr<T>() const noexcept; weak_ptr<T> exchange(weak_ptr<T> desired, memory_order order = memory_order::seq_cst) noexcept; bool compare_exchange_weak(weak_ptr<T>& expected, weak_ptr<T> desired, memory_order success, memory_order failure) noexcept; bool compare_exchange_strong(weak_ptr<T>& expected, weak_ptr<T> desired, memory_order success, memory_order failure) noexcept; bool compare_exchange_weak(weak_ptr<T>& expected, weak_ptr<T> desired, memory_order order = memory_order::seq_cst) noexcept; bool compare_exchange_strong(weak_ptr<T>& expected, weak_ptr<T> desired, memory_order order = memory_order::seq_cst) noexcept; constexpr atomic() noexcept = default; atomic(weak_ptr<T> desired) noexcept; atomic(const atomic&) = delete; void operator=(const atomic&) = delete; void operator=(weak_ptr<T> desired) noexcept; private: weak_ptr<T> p; // 설명 전용 }; }
클래스 템플릿 std:: out_ptr_t
namespace std { template<class Smart, class Pointer, class... Args> class out_ptr_t { public: explicit out_ptr_t(Smart&, Args...); out_ptr_t(const out_ptr_t&) = delete; ~out_ptr_t(); operator Pointer*() const noexcept; operator void**() const noexcept; private: Smart& s; // 설명 전용 tuple<Args...> a; // 설명 전용 Pointer p; // 설명 전용 }; }
클래스 템플릿 std:: inout_ptr_t
namespace std { template<class Smart, class Pointer, class... Args> class inout_ptr_t { public: explicit inout_ptr_t(Smart&, Args...); inout_ptr_t(const inout_ptr_t&) = delete; ~inout_ptr_t(); operator Pointer*() const noexcept; operator void**() const noexcept; private: Smart& s; // 설명 전용 tuple<Args...> a; // 설명 전용 Pointer p; // 설명 전용 }; }
클래스 템플릿 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; // 생성자 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(/* 설명 참조 */); 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); // 소멸자 constexpr ~indirect(); // assignment constexpr indirect& operator=(const indirect& other); constexpr indirect& operator=(indirect&& other) noexcept(/* 설명 참조 */); 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(/* 설명 참조 */); friend constexpr void swap(indirect& lhs, indirect& rhs) noexcept(/* 설명 참조 */); // 관계 연산자 template<class U, class AA> friend constexpr bool operator==( const indirect& lhs, const indirect<U, AA>& rhs) noexcept(/* 설명 참조 */); template<class U, class AA> friend constexpr auto operator<=>(const indirect& lhs, const indirect<U, AA>& rhs) -> /*synth-three-way-result*/<T, U>; // T와의 비교 template<class U> friend constexpr bool operator==(const indirect& lhs, const U& rhs) noexcept(/* 설명 참조 */); 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 /*할당*/ = 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; // 생성자 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(/* 설명 참조 */); 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); // 소멸자 constexpr ~polymorphic(); // 할당 constexpr polymorphic& operator=(const polymorphic& other); constexpr polymorphic& operator=(polymorphic&& other) 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; // 교환 constexpr void swap(polymorphic& other) noexcept(/* 설명 참조 */); friend constexpr void swap(polymorphic& lhs, polymorphic& rhs) noexcept(/* 설명 참조 */); private: Allocator /*alloc*/ = Allocator(); // 설명 전용 }; }