std::experimental::pmr:: resource_adaptor, std::pmr::experimental:: resource_adaptor
|
template
<
class
Alloc
>
using
resource_adaptor
=
/*resource-adaptor-imp*/
<
|
(库基础技术规范) | |
|
template
<
class
Alloc
>
class /*resource-adaptor-imp*/ : public memory_resource ; // 仅用于说明 |
(库基础技术规范) | |
别名模板
resource_adaptor
通过
memory_resource
接口适配分配器类型
Alloc
。分配器在实际适配前(使用
resource-adaptor-imp
类模板)会重新绑定到
char
值类型,因此适配同一分配器模板的特化始终生成相同类型,无论该分配器模板最初实例化时采用何种值类型。
|
|
(库基础技术规范)
(直至库基础技术规范 v3) |
|
|
(库基础技术规范 v3) |
resource-adaptor-imp
是一个类模板,其成员将在下文进行说明。名称
resource-adaptor-imp
仅用于说明目的,并非规范性表述。
除了满足
Allocator
要求外,
Alloc
还必须额外满足以下要求:
- std:: allocator_traits < Alloc > :: pointer 应与 Alloc :: value_type * 完全相同。
- std:: allocator_traits < Alloc > :: const_pointer 应与 Alloc :: value_type const * 完全相同。
- std:: allocator_traits < Alloc > :: void_pointer 应与 void * 完全相同。
- std:: allocator_traits < Alloc > :: const_const_pointer 应与 void const * 完全相同。
resource-adaptor-imp 的成员类型
| 成员类型 | 定义 |
allocator_type
|
Alloc
|
resource-adaptor-imp 的成员函数
resource-adaptor-imp :: resource-adaptor-imp
|
/*resource-adaptor-imp*/
(
)
=
default
;
|
(1) | (库基础技术规范) |
|
/*resource-adaptor-imp*/
(
const
/*resource-adaptor-imp*/
&
other
)
= default ; |
(2) | (库基础技术规范) |
|
/*resource-adaptor-imp*/
(
/*resource-adaptor-imp*/
&&
other
)
= default ; |
(3) | (库基础技术规范) |
|
explicit
/*resource-adaptor-imp*/
(
const
Alloc
&
a2
)
;
|
(4) | (库基础技术规范) |
|
explicit
/*resource-adaptor-imp*/
(
Alloc
&&
a2
)
;
|
(5) | (库基础技术规范) |
other
包装的分配器拷贝构造包装的分配器。
other
包装的分配器移动构造包装的分配器。
a2
初始化包装的分配器。
参数
| other | - |
用于拷贝或移动的另一个
resource-adaptor-imp
对象
|
| a2 | - |
用于拷贝或移动的另一个
Alloc
对象
|
resource-adaptor-imp :: get_allocator
|
allocator_type get_allocator
(
)
const
;
|
(library fundamentals TS) | |
返回被包装分配器的副本。
resource-adaptor-imp :: operator=
|
/*resource-adaptor-imp*/
&
operator
=
(
const
/*resource-adaptor-imp*/
&
other
)
= default ; |
(library fundamentals TS) | |
默认化的拷贝赋值运算符。从
other
的包装分配器进行拷贝赋值。
resource-adaptor-imp :: do_allocate
|
protected
:
virtual void * do_allocate ( std:: size_t bytes, std:: size_t alignment ) ; |
(library fundamentals TS) | |
使用被包装分配器的
allocate
成员函数分配内存。
resource-adaptor-imp :: do_deallocate
|
protected
:
virtual void do_deallocate ( void * p, std:: size_t bytes, std:: size_t alignment ) ; |
(library fundamentals TS) | |
使用包装分配器的
deallocate
成员函数来释放由
p
指向的存储空间。
p
必须是通过与包装分配器比较相等的分配器的
allocate
成员函数分配的,且之后未被释放。
resource-adaptor-imp :: do_is_equal
|
protected
:
virtual bool do_is_equal ( const memory_resource & other ) const noexcept ; |
(库基础技术规范) | |
令
p
为
dynamic_cast
<
const
/*resource-adaptor-imp*/
*
>
(
&
other
)
。若
p
为空指针值,则返回
false
。否则,返回通过
operator
==
比较
*
p
与
*
this
所包装分配器的结果。