【发布时间】:2019-10-08 13:46:11
【问题描述】:
cppreference 写道,模板参数包是模板参数:
https://en.cppreference.com/w/cpp/language/parameter_pack
这是真的吗?例如,这样写是否正确:
template<typename... Ts>
class MyClass {
std::unique_ptr<Ts...> m_data;
};
【问题讨论】:
-
想一想...使用您展示的代码,您可以执行
MyClass<int, double, MyOtherStructure> my_object;。这意味着你有std::unique_ptr<int, double, MyOtherStructure> m_data;。这是无效的。 -
你把
...放错地方了:必须是template<typename... T>
标签: c++ templates variadic-templates terminology