Here\'s a variadic template function that I\'ve written:
template
Value& insert(Container& c, Args&
The error is due to the missing ellipsis (...
) after args
when passing all individual parameters (rather than the parameter pack) to emplace_back
.
The fixed (and improved) version:
template<class Container, class... Args>
auto insert(Container& c, Args&&... args) -> decltype (c.back()) {
c.emplace_back(std::forward<Args>(args)...);
return c.back();
}