Constructor arguments from tuple

后端 未结 5 953
礼貌的吻别
礼貌的吻别 2020-12-01 19:41

Suppose I have a template which is parametrized by a class type and a number of argument types. a set of arguments matching these types are stored in a tuple. How can one pa

5条回答
  •  星月不相逢
    2020-12-01 20:18

    C++14 will add standard support for index_sequence:

    template
    struct foo {
      tuple args;
      T gen() { return gen_impl(std::index_sequence_for()); }
    private:
      template 
      T gen_impl(std::index_sequence) { return T(std::get(args)...); }
    };
    

提交回复
热议问题