std::scoped_allocator_adaptor<OuterAlloc,InnerAlloc...>::allocate
来自cppreference.com
< cpp | memory | scoped allocator
adaptor
动态内存管理
|
std::scoped_allocator_adaptor
成员函数 | ||||
scoped_allocator_adaptor::allocate
|
||||
非成员函数 | ||||
(C++20
前)
|
||||
推导指引(C++17) |
在标头
<scoped_allocator>
定义
|
||
(1) | ||
pointer
allocate(
size_type n );
|
(C++11
起) (C++20 前) |
|
[[nodiscard]]
pointer allocate(
size_type n );
|
(C++20 起) | |
(2) | ||
pointer
allocate(
size_type n, const_void_pointer
hint );
|
(C++11
起) (C++20 前) |
|
[[nodiscard]]
pointer allocate(
size_type n, const_void_pointer
hint );
|
(C++20 起) | |
用外层分配器分配未初始化存储。
1) 调用 std::allocator_traits<OuterAlloc>::allocate(outer_allocator(),
n)
2) 附带提供内存位置提示,通过调用 std::allocator_traits<OuterAlloc>::allocate(outer_allocator(),
n, hint)
参数
n | - | 要分配存储的对象数 |
hint | - | 指向临近内存位置的指针 |
返回值
指向分配存储的指针
参阅
分配未初始化的存储 ( std::allocator<T>
的公开成员函数) |
|
[静态]
|
用分配器分配未初始化的存储 ( std::allocator_traits<Alloc>
的公开静态成员函数) |