2
我在写第一个可变参数函数模板。我收到错误error: parameter packs not expanded with ‘...’:
。可能我在这里无法理解一些简单的概念。我想将所有通过iterators
存入vector
。什么是正确的方法来做到这一点?检查等长度的STL容器的变量函数
template<typename... Iterator>
bool IsEqualLength(Iterator&... its)
{
std::vector<Iterator> vec_its {its...};
int head = vec_its.front().size();
bool is_diff_size = std::any_of(vec_its.begin(), vec_its.end(),
[&head](Iterator& cur){return cur.size() != head;});
if(is_diff_size)
{
return false;
} else {
return true;
}
}
这失败(下GCC 4.8.4在Ubuntu)编译:
../proc.h: In function ‘bool IsEqualLength(Iterator& ...)’:
../proc.h:32:24: error: parameter packs not expanded with ‘...’:
std::vector<Iterator> vec_its {its...};
^
../proc.h:32:24: note: ‘Iterator’
../proc.h:35:87: error: parameter packs not expanded with ‘...’: