dimanche 24 novembre 2019

Variadic template as base class

I have the following base class:

template<typename Ret, typename ... _Args>
class Base {
public:
    Base() {
    }
    virtual ~Base() = default;

    void foo(_Args&&... __args) {
        //something here
    }
protected:
    virtual void pre() {
    }
    virtual void work(_Args&&... __args) = 0;
    virtual void post(Ret&& res) {
    }
};

and the following child class:

class C: public Base<double, int> {
public:
    virtual void pre() {
    }
    virtual void work(int&&... __args) {
    }
    virtual void post(double&& res) {
    }
};

Compiler says:

expansion pattern ‘int&&’ contains no argument packs

What am I missing?

Aucun commentaire:

Enregistrer un commentaire