小编Tho*_*mas的帖子

拆分可变参数模板参数

如何将可变参数模板参数分成两半?就像是:

template <int d> struct a {
  std::array <int, d> p, q;
  template <typename ... T> a (T ... t) : p ({half of t...}), q ({other half of t...}) {} 
};
Run Code Online (Sandbox Code Playgroud)

c++ variadic-templates c++11

23
推荐指数
2
解决办法
4809
查看次数

c ++初始化列表和可变参数模板

我想创建一个数组:

template < typename T, typename ... A > struct a {
  T x [1 + sizeof... (A)];
  a () = default;
  a (T && t, A && ... y) : x { t, y... } {}
};

int main () {
  a < int, int > p { 1, 1 }; // ok
  a < a < int, int >, a < int, int > > q { { 1, 1 }, { 3, 3 } }; // error: …
Run Code Online (Sandbox Code Playgroud)

c++ initializer-list variadic-templates c++11

6
推荐指数
1
解决办法
997
查看次数

标签 统计

c++ ×2

c++11 ×2

variadic-templates ×2

initializer-list ×1