定义于头文件
<memory>
|
||
template< class T, class Alloc > struct uses_allocator;
|
(C++11 起) | |
若 T
拥有:1)内嵌定义类型 allocator_type
,并且该类型能从 Alloc
转换,2)或者该类型是 std::experimental::erased_type 的别名 (库基础 TS),则成员常量 value
为 true 。否则 value
为 false 。
目录 |
template< class T, class Alloc >
inline constexpr bool uses_allocator_v = uses_allocator<T, Alloc>::value; |
(C++17 起) | |
value
[静态]
|
若 T 使用分配器 Alloc 则为 true ,否则为 false (公开静态成员常量) |
operator bool
|
转换对象为 bool ,返回 value (公开成员函数) |
operator()
(C++14)
|
返回 value (公开成员函数) |
类型 | 定义 |
value_type
|
bool
|
type
|
std::integral_constant<bool, value> |
类型特性 std::uses_allocator 的自定义特化对无成员 typedef allocator_type
的类型允许,但必须满足下列二个要求之一:
T
拥有接收 std::allocator_arg_t 为首参数, Alloc
为第二参数的构造函数。T
拥有接收 Alloc
为最后参数的构造函数。上述情况中, Alloc
是满足分配器 (Allocator
) 要求的类型,或是可转换到 std::experimental::pmr::memory_resource* 的指针类型 (库基础 TS)。
标准库已提供下列特化:
(C++11)
|
特化 std::uses_allocator 类型特性 (类模板特化) |
(C++11)
|
特化 std::uses_allocator 类型特性 (函数模板) |
特化 std::uses_allocator 类型特性 (函数模板) |
|
(C++11)
|
特化 std::uses_allocator 类型特性 (函数模板) |
(C++11) (C++17 前)
|
特化 std::uses_allocator 类型特性 (类模板特化) |
特化 std::uses_allocator 类型特性 (类模板特化) |
|
(C++11)(C++17 前)
|
特化 std::uses_allocator 类型特性 (类模板特化) |
此类型特性为 std::scoped_allocator_adaptor 、 std::tuple 、 std::variant 及 std::pmr::polymorphic_allocator 所用。它亦可为自定义分配器或封装类型所用,以确定要构造的对象或成员是否足以使用分配器(例如是容器的情况),该情况下应传递给其构造函数分配器。
(C++11)
|
用于选择具分配器的构造函数的 std::allocator_arg_t 对象 (常量) |
(C++11)
|
标签类型,用于选择分配器感知的构造函数重载 (类) |
(C++11)
|
为多级容器实现的多级分配器 (类模板) |