Namespaces
Variants

std::pmr::polymorphic_allocator<T>:: allocate_bytes

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)
void * allocate_bytes ( std:: size_t nbytes,
std:: size_t alignment = alignof ( std:: max_align_t ) ) ;
(C++20부터)

지정된 정렬 alignment nbytes 바이트의 저장 공간을 기본 메모리 리소스를 사용하여 할당합니다. 다음 코드와 동일합니다: return resource ( ) - > allocate ( nbytes, alignment ) ; .

목차

매개변수

nbytes - 할당할 바이트 수
alignment - 사용할 정렬 방식

반환값

할당된 저장소에 대한 포인터.

참고 사항

이 함수는 완전히 특수화된 할당자 std:: pmr :: polymorphic_allocator <> 와 함께 사용하기 위해 도입되었으나, 어떤 특수화에서도 유용할 수 있습니다.

반환 타입은 void * 입니다(예를 들어 std:: byte * 가 아닙니다). 이는 static_cast < U * > 를 통해 임의의 포인터 타입 U * 로의 변환을 지원하기 위함입니다.

예외

resource ( ) - > allocate 호출 시 발생할 수 있는 모든 예외를 던질 수 있습니다.

참고 항목

객체나 배열에 적합한 원시 메모리를 할당함
(public member function)
(C++20)
객체를 할당하고 생성함
(public member function)
메모리를 할당함
(public member function)
[static]
할당자를 사용하여 초기화되지 않은 저장 공간을 할당함
( std::allocator_traits<Alloc> 의 public static member function)
메모리를 할당함
( std::pmr::memory_resource 의 public member function)