std::allocator_traits<Alloc>::construct
来自cppreference.com
                    
                                        
                    < cpp | memory | allocator traits
                    
                                                            
                    |   在标头  <memory> 定义
  | 
||
|   template< class T, class... Args > static void construct( Alloc& a, T* p, Args&&... args );  | 
 (C++11 起)  (C++20 前)  | 
|
|   template< class T, class... Args > static constexpr void construct( Alloc& a, T* p, Args&&... args );  | 
(C++20 起) | |
若可能,则在 p 所指向的分配的未初始化存储构造 T 类型对象,通过调用
a.construct(p, std::forward<Args>(args)...)
若以上不可行(例如 Alloc 无 construct() 成员函数),则调用
| 
 ::new (static_cast<void*>(p)) T(std::forward<Args>(args)...)  | 
(C++20 前) | 
| 
 std::construct_at(p, std::forward<Args>(args)...)  | 
(C++20 起) | 
参数
| a | - | 用于构造的分配器 | 
| p | - |   指向未初始化存储的指针,将在其上构造 T 对象
 | 
| args... | - |   传递给 a.construct() 或布置 new (C++20 前) std::construct_at() (C++20 起) 的参数
 | 
返回值
(无)
注解
此函数为标准库容器在插入、复制或移动元素时所用。
因为此函数提供到布置 new 的自动回落,故 C++11 起成员函数 construct() 是分配器 (Allocator) 的可选要求。
参阅
|    分配函数   (函数)  | |
|    (C++17 中弃用)(C++20 中移除)  | 
  在分配的存储构造对象  ( std::allocator<T> 的公开成员函数)  |