提升 - 类模板队列
BOOST - Class template queue
我试图在 Boost 类模板队列上阅读,发现类模板的以下内容:
template<typename T, typename A0, typename A1, typename A2>
class queue {
public:
// member classes/structs/unions
template<typename T, typename... Options>
struct implementation_defined {
// types
typedef node_allocator allocator;
typedef std::size_t size_type;
};
// construct/copy/destruct
queue(void);
template<typename U>
explicit queue(typename node_allocator::template rebind< U >::other const &);
explicit queue(allocator const &);
explicit queue(size_type);
template<typename U>
queue(size_type,
typename node_allocator::template rebind< U >::other const &);
~queue(void);
.......
};
我试图一步一步地理解模板 - 所以
template<typename T, typename A0, typename A1, typename A2>
对我来说意味着当提供类型 T、A0、A1 和 A2 时将创建模板,例如
queue<int, char, myclass, char>
其中myclass是一个用户定义的类 - 我希望我的理解是正确的。但我无法理解的是以下部分——
template<typename T, typename... Options>
struct implementation_defined {
// types
typedef node_allocator allocator;
typedef std::size_t size_type;
};
// construct/copy/destruct
queue(void);
template<typename U>
explicit queue(typename node_allocator::template rebind< U >::other const &);
它似乎是另一个模板中的模板 - 但是我们如何提供类型来实例化
template<typename T, typename... Options>
和
template<typename U>
有没有办法像类一样理解模板构造,以了解模板方法的参数和返回类型是什么?
template<typename U>
是一个queue
构造函数模板。它的参数是从调用它时传递的参数推断出来的。
struct implementation_defined
是一个常规的嵌套类,实际上并不是模板本身。它看起来像一个文档问题,因为它实际上被定义为
struct implementation_defined
{
typedef node_allocator allocator;
typedef std::size_t size_type;
};
相关文章:
- 内存排序在提升::无锁:队列
- 提升消息队列 跨两个进程未接收
- 如何检查提升消息队列是否存在
- 提升 - 类模板队列
- 可以提升 asio 帖子"overflow"队列
- 使用提升库在队列和堆栈数据结构上保存和加载数据时出错
- 可以检查提升::无锁::队列是否已满吗?
- 两个提升的无锁队列会导致僵局
- 提升优先级队列比较功能
- 提升优先级队列,查看元素是否已在队列中
- 比较提升::无锁::spsc_queue、提升::无锁::队列、串行队列操作
- 试图理解提升队列示例
- 创建固定大小队列的向量(提升循环队列)
- C++ 阻塞队列隔离错误带提升
- 使用提升线程监视对象队列
- 提升优先级队列迭代器
- 视觉提升 条件变量中的同步队列C++不通知其他线程上的等待类方法
- 提升c++无锁队列与共享队列的对比
- 提升线程间通信队列
- 如何使提升::无锁::队列动态调整大小