std::uses_allocator<std::tuple>
来自 cppreference.cn
定义于头文件 <tuple> |
||
template< class... Types, class Alloc > struct uses_allocator< std::tuple<Types...>, Alloc > : std::true_type { }; |
(C++11 起) | |
此 std::uses_allocator 的特化告知其他库组件,即使元组没有嵌套的 allocator_type
,它们也支持*uses-allocator 构造*。
目录 |
继承自 std::integral_constant
成员常量
value [静态] |
true (public static 成员常量) |
成员函数
operator bool |
将对象转换为 bool,返回 value (公开成员函数) |
operator() (C++14) |
返回 value (公开成员函数) |
成员类型
类型 | 定义 |
value_type
|
bool |
类型
|
std::integral_constant<bool, value> |
[编辑] 示例
// myalloc is a stateful Allocator with a single-argument constructor // that takes an int. It has no default constructor. using innervector_t = std::vector<int, myalloc<int>>; using elem_t = std::tuple<int, innervector_t>; using Alloc = std::scoped_allocator_adaptor< myalloc<elem_t>, myalloc<int>>; Alloc a(1,2); std::vector<elem_t, Alloc> v(a); v.resize(1); // uses allocator #1 for elements of v std::get<1>(v[0]).resize(10); // uses allocator #2 for innervector_t
[编辑] 另请参阅
(C++11) |
检查指定类型是否支持 uses-allocator 构造 (类模板) |