Here's a variadic template function that I've written:
template<class Container, class Value, class... Args>
Value& insert(Container& c, Args&&... args) {
c.emplace_back(args);
return c.back();
}
When I use insert
like this I'm getting an error:
list<int> lst;
int& num = insert<list<int>, int, int>(lst, 4);
The error complains about this line in the body of insert
:
c.emplace_back(args); // <= 'args' : parameter pack must be
// expanded in this context
What does that mean and how can I fix it?