lundi 20 juillet 2015

Is there a way to specify all classes in a variadic parameter pack to be friend of the template in order to use operator=?

I have seen a CRTP solution, which extracted the interface into the base class, and friended only one of the pack arguments. Then the last class inherited all the friended base classes and implemented the interface.

I cannot use this approach, since I need to protect the assignment operator, which since it is not inherited.

Also, since the assignment operator requires none additional parameters, I cannot use a key pattern.

This is what I would like to have:

template <typename... F>
struct A {
protected:
    A& operator=() {
    }
private:
    friend F...;
}

Is there a way to do what I am needing?

Aucun commentaire:

Enregistrer un commentaire