Basically I need template function, that would compare container's size with some constant. So I need to make std::vector of containers and check if predicate compSize is true.
template < int x, class Container >
bool compSize(Container cont)
{
return x == cont.size();
}
template < int x, class ...Container >
bool compSizeMult(Container ...conts)
{
std::vector< Container > cvector{ conts... };
return std::all_of(cvector.cbegin(), cvector.cend(), compSize< x, Container >);
}
But compiler says, that parameter pack is not expanded at
cvector{ conts... };
Also I would like to use compSizeMult as comparator for std::sort and make something like
int main()
{
std::vector< std::vector< int > > vec{{1}, {2}, {3}, {0}, {0}};
std::sort(vec.begin(), vec.end(), compSizeMult< 0, std::vector< int > >);
}
that's why function is supposed to take multiple arguments. I can't use loops and lambdas in this task, only standard algorithms