Recently I wanted to implement implicit sharing functionality like Qt does with its QSharedData
and QSharedDataPointer
classes, so I took a look at their sources and in the place of QSharedData
I found these three lines:
private:
// using the assignment operator would lead to corruption in the ref-counting
QSharedData &operator=(const QSharedData &);
However I don't understand how could operator=
break reference counting.
If I just did not make it private and left its implementation empty, wouldn't it serve the same purpose ?
i.e. if I wrote simply this:
public:
QSharedData &operator=(const QSharedData & ) { return *this; }