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
auto insert(Container& c, Args&&... args) -> decltype (c.back()) {
c.emplace_back(std::forward(args)...);
return c.back();
}