Namespaces
Variants

std::scoped_allocator_adaptor<OuterAlloc,InnerAlloc...>:: allocate

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)
定义于头文件 <scoped_allocator>
pointer allocate ( size_type n ) ;
(1) (C++11 起)
pointer allocate ( size_type n, const_void_pointer hint ) ;
(2) (C++11 起)

使用外部分配器分配未初始化的存储空间。

1) 调用 std:: allocator_traits < OuterAlloc > :: allocate ( outer_allocator ( ) , n )
2) 额外提供内存局部性提示,通过调用 std:: allocator_traits < OuterAlloc > :: allocate ( outer_allocator ( ) , n, hint )

参数

n - 要分配存储空间的对象数量
hint - 指向附近内存位置的指针

返回值

指向已分配存储的指针。

参见

分配未初始化的存储空间
( std::allocator<T> 的公开成员函数)
[static]
使用分配器分配未初始化的存储空间
( std::allocator_traits<Alloc> 的公开静态成员函数)