void construct( U* p, Args&&... args ); (2) (C++11 起)(C++17 中弃用)(C++20 中移除) 用布置 new ,在 p 所指的未初始化存储中构造 T 类型对象。1) 调用 new((void *)p) T(val) 2) 调用 ::new((void *)p) U(std::forward<Args>(args)...) 参数 p - 指向未初始化存储的指针 ...
从C++17起,std::allocator自身只负责内存分配,不负责对象construct与destory(这两个函数已经弃用)。换...
std::pmr::polymorphic_allocator::construct std::pmr::polymorphic_allocator::deallocate std::pmr::polymorphic_allocator::destroy std::pmr::polymorphic_allocator::polymorphic_allocator std::pmr::polymorphic_allocator::resource std::pmr::polymorphic_allocator::select_on_container_copy_construction ...
std::allocator<T>::construct 定义于头文件<memory> voidconstruct(pointer p, const_reference val); (1)(C++11 前) template<classU,class...Args> voidconstruct(U*p, Args&&...args); (2)(C++11 起) (C++17 中弃用) (C++20 中移除)
void construct( U* p, Args&&... args ); (2) (C++11 起) (C++17 弃用) (C++20 移除) 用全局的布置 new,在 p 指向的未初始化存储中构造 T 类型对象。 1) 调用::new((void*)p) T(val)。2) 调用::new((void*)p) U(std::forward<Args>(args)...)。参数...
std::uninitialized_construct_using_allocator std::pmr::polymorphic_allocator std::pmr::get_default_resource std::pmr::set_default_resource std::pmr::new_delete_resource std::pmr::null_memory_resource std::pmr::synchronized_pool_resource std::pmr::unsynchronized_pool_resource std::pmr::monotonic...
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 起)...
If the above is not possible (e.g.Allocdoes not have the member functionconstruct()), then calls ::new(static_cast<void*>(p))T(std::forward<Args>(args)...) (until C++20) std::construct_at(p,std::forward<Args>(args)...) ...
allocatro分配的内存是未构造的(unconstructed)。我们按需要在此内存中构造对象。在新标准库中,construct成员函数接受一个指针和零个或多个额外参数,在给定位置构造一个元素。额外参数用来初始化构造的对象。类似make_shared的参数,这些额外参数必须是与构造的对象的类型相匹配的合法的初始化器。
construct:用于构造对象,在C++ 20中也被移除了。 destroy:用于销毁分配的存储中的对象。在 C++ 20 中也将其删除。 max_size:返回支持的最大分配大小。在 C++ 17 中已弃用,在 C++ 20 中已删除。 allocate:用于分配内存。 deallocate:用于内存的释放。