Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我似乎无法解决这个问题。有没有办法初始化一个元组,其中每个元素都采用相同的参数?例如...
template <class... args> std::tuple<args...> tuplemaker(int n) { // What goes here? } auto my_tuple = tuplemaker<int, int, int>(42);
可以肯定的是一个人为的例子。我真正想做的是将相同的参数重复传递给我的元组元素的构造函数。有人有建议吗?
像这样的东西:
template <class... args> std::tuple<args...> tuplemaker(int n) { return std::make_tuple(args(n)...); }
现场示例在这里。