Variable number of constructor parameters depending on integer template

后端 未结 3 1022
感动是毒
感动是毒 2021-01-03 02:51

I\'m writing a container storage class template that wraps a private std::array in order to add some functionality to it. The template parametrises the number o

3条回答
  •  醉话见心
    2021-01-03 03:14

    By following Member function template with the number of parameters depending on an integral template parameter and Variadic templates with exactly n parameters, have got it working with the following code.

    template class Vector {
    private:
        array vals;
    public:
        template ::type = 0>
        Vector(T ...args) : vals{args} {}
    };
    

提交回复
热议问题