Error with variadiac template: “parameter pack must be expanded”

拟墨画扇 提交于 2019-12-04 00:53:31
Jarod42

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();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!