I am writing my first variadic function template. I am getting the error error: parameter packs not expanded with ‘...’:. Probably I cannot understand some easy concept here. I would like to store all passed in iterators in a vector. What is the right way to do this?
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;
}
}
This fails to compile with (under gcc 4.8.4 on 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 ‘...’:
Aucun commentaire:
Enregistrer un commentaire