Namespaces
Variants

std:: indirect

From cppreference.net
Memory management library
( exposition only* )
Allocators
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
( until C++20* )
( until C++20* )
( until C++20* )

Garbage collector support (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
헤더 파일에 정의됨 <memory>
template < class T, class Allocator = std:: allocator < T > >
class indirect ;
(1) (C++26부터)
namespace pmr {

template < class T >
using indirect = std :: indirect < T, std:: pmr :: polymorphic_allocator < T >> ;

}
(2) (C++26부터)
1) std::indirect 는 값(value) 의미 체계를 가진 동적으로 할당된 객체를 포함하는 래퍼입니다.
2) std::pmr::indirect polymorphic allocator 를 사용하는 별칭 템플릿입니다.

std::indirect 객체는 소유한 객체의 수명 을 관리합니다. std::indirect 객체는 이동된 후에만 소유한 객체를 갖지 않을 수 있으며, 이 경우 값이 없는(valueless) 상태가 됩니다.

std::indirect<T, Allocator> 타입의 모든 객체는 필요에 따라 소유한 객체의 저장 공간을 할당하고 해제하기 위해 Allocator 타입의 객체를 사용합니다.

프로그램이 std::indirect 의 명시적 또는 부분 특수화를 선언하는 경우, 그 동작은 정의되지 않습니다.

목차

템플릿 매개변수

T - 소유한 객체의 타입
Allocator - 연관된 할당자의 타입
타입 요구사항
-
T 불완전한 타입 일 수 있습니다.
-
만약 T 가 다음 타입 중 하나라면 프로그램은 형식에 맞지 않습니다:
-
만약 Allocator Allocator 요구사항을 만족하지 않으면 프로그램은 형식에 맞지 않습니다.
-
만약 std:: allocator_traits < Allocator > :: value_type T 와 동일한 타입이 아니면 프로그램은 형식에 맞지 않습니다.

중첩 타입

유형 정의
value_type T
allocator_type Allocator
pointer typename std:: allocator_traits < Allocator > :: pointer
const_pointer typename std:: allocator_traits < Allocator > :: const_pointer

데이터 멤버

멤버 설명
pointer p 소유한 값에 대한 포인터
( 설명 전용 멤버 객체* )
Allocator alloc 연관된 할당자
( 설명 전용 멤버 객체* )

멤버 함수

indirect 객체를 생성합니다
(public member function)
소유한 값이 있는 경우 파괴합니다
(public member function)
내용을 할당합니다
(public member function)
Observers
소유한 값에 접근합니다
(public member function)
indirect 가 값을 가지고 있지 않은지 확인합니다
(public member function)
연결된 할당자를 반환합니다
(public member function)
Modifiers
내용을 교환합니다
(public member function)

비멤버 함수

(C++26) (C++26)
indirect 객체 비교
(함수 템플릿)
std::swap 알고리즘 특수화
(함수 템플릿)

헬퍼 클래스

std::indirect 에 대한 해시 지원
(클래스 템플릿 특수화)

추론 가이드

참고 사항

기능 테스트 매크로 표준 기능
__cpp_lib_indirect 202502L (C++26) std::indirect

예제

참고 항목

값(value-like) 의미론을 가지는 동적으로 할당된 객체를 포함하는 다형성 래퍼
(클래스 템플릿)
(C++11)
고유한 객체 소유권 의미론을 가지는 스마트 포인터
(클래스 템플릿)