【发布时间】:2023-03-09 21:08:01
【问题描述】:
我想实例化一个类喜欢
template<typename ...Args>
class X {
private:
std::tuple<std::array<Arg0, 255>, std::array<Arg1, 255>, ...> m_tuples; // For Arg in Args
}
我知道这不是正确的C++,但是如何实现将类的参数包模板扩展为元组中保存的数组的效果?
【问题讨论】:
我想实例化一个类喜欢
template<typename ...Args>
class X {
private:
std::tuple<std::array<Arg0, 255>, std::array<Arg1, 255>, ...> m_tuples; // For Arg in Args
}
我知道这不是正确的C++,但是如何实现将类的参数包模板扩展为元组中保存的数组的效果?
【问题讨论】:
template<typename ...Args>
class X {
private:
std::tuple<std::array<Args, 255>...> m_tuples; // For Arg in Args
};
...你没想到会如此接近,是吗:)
【讨论】:
std::array<Args, 255>,通过替换 Args 可以扩展为您所追求的。