std::uses_allocator
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <memory> 中定义
|
||
template< class T, class Alloc > struct uses_allocator |
(C++11 起) | |
如果
T
有一个的成员typedefallocator_type
,这是转换从Alloc
,提供了不变value
等于true。否则value
是false.原文:
If
T
has a member typedef allocator_type
which is convertible from Alloc
, provides the member constant value
equal to true. Otherwise value
is false.目录 |
Inherited from std::integral_constant
Member constants
value [静态的]</div></div>
|
true如果 T uses allocator Alloc ,false其他方式 原文: true if T uses allocator Alloc , false otherwise (公共静态成员常量) |
Member functions
operator bool |
转换的对象bool,返回 value 原文: converts the object to bool, returns value (公共成员函数) |
Member types
类型
|
Definition |
value_type
|
bool
|
type
|
std::integral_constant<bool, value> |
</div>
[编辑] 专业化
自定义的类型特征std::uses_allocator所允许的类型,不具备的成员typedef
1) allocator_type
但满足以下两个条件之一的专业原文:
Custom specializations of the type trait std::uses_allocator are allowed for types that do not have the member typedef
allocator_type
but satisfy one of the following two requirements:T
有std::allocator_arg_t作为第一个参数,Alloc
作为第二个参数的构造函数,.原文:
T
has a constructor which takes std::allocator_arg_t as the first argument, and Alloc
as the second argument.T
有Alloc
作为最后一个参数的构造函数,.原文:
T
has a constructor which takes Alloc
as the last argument.以下专业的标准库已经提供了
原文:
The following specializations are already provided by the standard library:
特化std::uses_allocator的类型特征 (类模板特化) | |
专业的std::uses_allocator型特征 原文: specializes the std::uses_allocator type trait (函数模板) | |
专业的std::uses_allocator型特征 原文: specializes the std::uses_allocator type trait (函数模板) | |
专业的std::uses_allocator型特征 原文: specializes the std::uses_allocator type trait (函数模板) | |
专业的std::uses_allocator型特征 原文: specializes the std::uses_allocator type trait (类模板特化) | |
专业的std::uses_allocator型特征 原文: specializes the std::uses_allocator type trait (类模板特化) | |
专业的std::uses_allocator型特征 原文: specializes the std::uses_allocator type trait (类模板特化) |
[编辑] 注释
此类型的特征是所使用的std::scoped_allocator_adaptor,并可以使用由自定义的分配,以确定是否正在构造的对象本身是能够使用一个分配器(例如是一个容器),在这种情况下,一个分配器应传递到其构造.
原文:
This type trait is used by std::scoped_allocator_adaptor and may be used by custom allocators to determine whether the object being constructed is itself capable of using an allocator (e.g. is a container), in which case an allocator should be passed to its constructor.
[编辑] 另请参阅
(C++11) |
一个对象的类型std::allocator_arg_t用来选择分配器感知的构造函数 原文: an object of type std::allocator_arg_t used to select allocator-aware constructors (常量) |
(C++11) |
使用的标签类型选择分配器感知的构造函数重载 原文: tag type used to select allocator-aware constructor overloads (类) |
(C++11) |
实现多级的多级容器分配器 原文: implements multi-level allocator for multi-level containers (类模板) |