【发布时间】:2016-01-28 02:41:56
【问题描述】:
我有一对begin()/end() 方法声明如下:
template <typename... Ts>
Iterator begin(Ts... indices) const;
template <typename... Ts>
Iterator end(Ts... indices) const;
从逻辑上讲,end() 可以用begin() 来实现。具体来说,end(x, y, ..., z) 等价于begin(x, y, ..., z + 1)。那么,有没有一种干净的方法可以使用indices 将x, y, ..., z 变成x, y, ..., z + 1,这样我就可以像实现end() 一样
template <typename... Ts>
Iterator end(Ts... indices) const {
return begin(whatever to do with indices...);
}
【问题讨论】:
标签: c++ c++14 variadic-templates template-meta-programming