std::pmr::polymorphic_allocator<T>::polymorphic_allocator

来自cppreference.com
 
 
内存管理库
(仅用于阐述*)
分配器
未初始化内存算法
受约束的未初始化内存算法
内存资源
未初始化存储 (C++20 前)
(C++17 弃用)
(C++17 弃用)
垃圾收集器支持 (C++23 前)
(C++11)(C++23 前)
(C++11)(C++23 前)
(C++11)(C++23 前)
(C++11)(C++23 前)
(C++11)(C++23 前)
(C++11)(C++23 前)
 
 
polymorphic_allocator() noexcept;
(1)
polymorphic_allocator( const polymorphic_allocator& other ) = default;
(2)
template< class U >
polymorphic_allocator( const polymorphic_allocator<U>& other ) noexcept;
(3)
polymorphic_allocator( std::pmr::memory_resource* r );
(4)

构造新的 polymorphic_allocator

1)std::pmr::get_default_resource() 的返回值为底层内存资源构造一个 polymorphic_allocator
2,3)other.resource() 为底层内存资源构造 polymorphic_allocator
4)r 为底层内存资源构造 polymorphic_allocator。此构造函数提供从 std::pmr::memory_resource* 的隐式转换。

参数

other-要复制的另一 polymorphic_allocator
r-指向要使用的内存资源的指针。不可为空。

异常

4) 不抛出任何异常。

注解

复制使用 polymorphic_allocator 的容器不会调用分配器的复制构造函数。新容器会替代地以 select_on_container_copy_construction 的返回值(默认构造的 polymorphic_allocator)为其分配器。

参阅

为容器的复制构造函数的使用创建一个新的 polymorphic_allocator
(公开成员函数)