Namespaces
Variants

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

From cppreference.net
Memory management library
( exposition only* )
Allocators
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
( until C++20* )
( until C++20* )
( until C++20* )

Garbage collector support (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until 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
(公开成员函数)