std::scoped_allocator_adaptor::allocate

定义于头文件 <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 的公开成员函数)
[静态]
用分配器分配未初始化的存储
(std::allocator_traits 的公开静态成员函数)

版本历史

  • (当前 | 先前 2017年11月13日 (一) 16:26Fruderica讨论 | 贡献 . . (1,128字节) (+191). . (P0600R1 nodiscard) (撤销)
  • 当前 | 先前 2017年6月4日 (日) 20:56Fruderica讨论 | 贡献. . (937字节) (-939). . (撤销)
  • 当前 | 先前 2013年7月2日 (二) 09:05P12bot讨论 | 贡献 . . (1,876字节) (-148). . (Use {{lc}}. Update links. Various fixes.) (撤销)
  • 当前 | 先前 2012年11月2日 (五) 15:33P12bot讨论 | 贡献 . . (2,024字节) (+417). . (r2.7.3) (机器人添加:de, en, es, fr, it, ja, pt, ru) (撤销)
  • 当前 | 先前 2012年10月27日 (六) 03:39P12讨论 | 贡献 . . (1,607字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 06:00TranslationBot讨论 | 贡献. . (1,607字节) (-49). . (Translated from the English version using Google Translate) (撤销)
  • 当前 | 先前 2012年10月25日 (四) 14:10P12讨论 | 贡献 . . (1,656字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前) 2012年10月25日 (四) 12:00TranslationBot讨论 | 贡献. . (1,656字节) (+1,656). . (Translated from the English version using Google Translate)