Created on 2016-10-31.00:00:00 last changed 99 months ago
An example like the following,
class A { private: A& operator=(const A&); }; class B : virtual public A { public: B& operator = (const B& src); }; class C: public B { public: void f(const C* psrc) { *this = *psrc; } };
is presumably well-formed, even though the copy assignment operator of A is inaccessible in C, because 11.4.6 [class.copy.assign] paragraph 12 says that only direct, not virtual, base class object assignment operators are invoked by the generated assignment operator (although there is implementation divergence on this question).
Should the example also be well-formed if A were a direct virtual base of C? That is, if a direct virtual base also has an indirect derivation path, its direct derivation can be ignored for generated assignment operators.
Possibly relevant to this question is the permission for an implementation to assign virtual base class objects more than once:
It is unspecified whether subobjects representing virtual base classes are assigned more than once by the implicitly-defined copy/move assignment operator.
History | |||
---|---|---|---|
Date | User | Action | Args |
2016-10-31 00:00:00 | admin | create |