Namespaces
Variants

std:: polymorphic

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 polymorphic ;
(1) (C++26부터)
namespace pmr {

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

}
(2) (C++26부터)
1) std::polymorphic 는 값(value) 의미론을 가지면서 서로 다른 타입의 동적 할당 객체를 포함하는 래퍼입니다.
2) std::pmr::polymorphic polymorphic allocator 를 사용하는 alias template입니다.

std::polymorphic 객체는 소유한 객체의 수명 을 관리합니다. 소유된 객체는 T 타입이거나 T 에서 (공개적이고 명확하게) 파생된 모든 타입입니다. std::polymorphic 객체는 이동된 후에만 소유한 객체를 갖지 않을 수 있으며, 이 경우 값이 없는 상태 입니다.

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

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

목차

템플릿 매개변수

T - 소유한 객체의 타입
Allocator - 연관된 할당자의 타입
타입 요구사항
-
T 불완전한 타입 일 수 있습니다.
-
다음 타입 중 하나인 경우 프로그램은 ill-formed입니다:
-
Allocator Allocator 요구사항을 만족하지 않는 경우, 프로그램은 ill-formed입니다.
-
std:: allocator_traits < Allocator > :: value_type T 와 동일한 타입이 아닌 경우, 프로그램은 ill-formed입니다.

중첩 타입

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

데이터 멤버

멤버 설명
Allocator alloc 연관된 할당자
( 설명 전용 멤버 객체* )

멤버 함수

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

비멤버 함수

std::swap 알고리즘을 특수화함
(함수 템플릿)

참고 사항

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

예제

참고 항목

(C++26)
값(value) 의미론을 가지는 동적으로 할당된 객체를 포함하는 래퍼
(클래스 템플릿)