Namespaces
Variants

std:: allocator_traits

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 Alloc >
struct allocator_traits ;
(C++11부터)

allocator_traits 클래스 템플릿은 Allocator s 의 다양한 속성에 접근하기 위한 표준화된 방법을 제공합니다. 표준 컨테이너와 다른 표준 라이브러리 구성 요소들은 이 템플릿을 통해 할당자에 접근합니다.

사용자가 제공하는 std::allocator_traits 의 특수화가 모든 필수 기능을 구현한다면 모든 클래스 타입을 할당자로 사용할 수 있습니다.

(C++23 이전)

std::allocator_traits 의 명시적 또는 부분 특수화를 선언하는 프로그램은 진단 없이 잘못된 형식입니다.

(C++23 이후)

기본, 비특수화된 std::allocator_traits 는 다음 멤버들을 포함합니다:

목차

멤버 타입

유형 정의
allocator_type Alloc
value_type Alloc::value_type
pointer Alloc::pointer 가 존재하는 경우, 그렇지 않으면 value_type*
const_pointer Alloc::const_pointer 가 존재하는 경우, 그렇지 않으면 std:: pointer_traits < pointer > :: rebind < const value_type >
void_pointer Alloc::void_pointer 가 존재하는 경우, 그렇지 않으면 std:: pointer_traits < pointer > :: rebind < void >
const_void_pointer Alloc::const_void_pointer 가 존재하는 경우, 그렇지 않으면 std:: pointer_traits < pointer > :: rebind < const void >
difference_type Alloc::difference_type 가 존재하는 경우, 그렇지 않으면 std:: pointer_traits < pointer > :: difference_type
size_type Alloc::size_type 가 존재하는 경우, 그렇지 않으면 std:: make_unsigned < difference_type > :: type
propagate_on_container_copy_assignment Alloc::propagate_on_container_copy_assignment 가 존재하는 경우, 그렇지 않으면 std::false_type
propagate_on_container_move_assignment Alloc::propagate_on_container_move_assignment 가 존재하는 경우, 그렇지 않으면 std::false_type
propagate_on_container_swap Alloc::propagate_on_container_swap 가 존재하는 경우, 그렇지 않으면 std::false_type
is_always_equal Alloc::is_always_equal 가 존재하는 경우, 그렇지 않으면 std:: is_empty < Alloc > :: type

멤버 별칭 템플릿

유형 정의
rebind_alloc<T> Alloc::rebind<T>::other 가 존재하는 경우, 그렇지 않으면 이 Alloc SomeAllocator < U, Args > 형태일 때 SomeAllocator<T, Args> , 여기서 Args 는 0개 이상의 타입 인자
rebind_traits<T> std :: allocator_traits < rebind_alloc < T >>

멤버 함수

[static]
할당자를 사용하여 초기화되지 않은 저장 공간을 할당함
(public static member function)
[static] (C++23)
할당자를 통해 요청된 크기 이상의 저장 공간을 할당함
(public static member function)
[static]
할당자를 사용하여 저장 공간을 해제함
(public static member function)
[static]
할당된 저장 공간에 객체를 생성함
(function template)
[static]
할당된 저장 공간에 저장된 객체를 소멸시킴
(function template)
[static]
할당자가 지원하는 최대 객체 크기를 반환함
(public static member function)
표준 컨테이너 복사 후 사용할 할당자를 얻음
(public static member function)

결함 보고서

다음의 동작 변경 결함 보고서들은 이전에 발표된 C++ 표준에 소급 적용되었습니다.

DR 적용 대상 게시된 동작 올바른 동작
LWG 2108 C++11 allocator가 상태 비저장임을 나타낼 방법이 없었음 is_always_equal 제공됨

참고 항목

할당자를 사용하는 컨테이너; 관련 특성(예: propagate_on_container_swap ) 사용법
(명명된 요구 사항)
기본 할당자
(클래스 템플릿)
다중 수준 컨테이너를 위한 다중 수준 할당자 구현
(클래스 템플릿)
포인터와 유사한 타입에 대한 정보 제공
(클래스 템플릿)