samedi 23 mai 2020

Is it possible for a class member function argument list to be dependent on a template argument?

Is there a way to write a templated class so that the signature/prototype of a member function is dependent on the template arguments? For instance, if I declare a class foo that takes an int N template argument, is it possible that the prototype of the member function foo::bar() has N same-type arguments? I am aware I cound just pass an std::array or std::vector as argument, but in the application I have in mind that wouldn't work.

template <int N>
class foo {
    std::array<float, N> _data;

 public:
    foo()  {};
    ~foo() {};

    void bar(float arg0, float arg1, float arg2 /*, ... */) const;
};

Aucun commentaire:

Enregistrer un commentaire