mardi 23 mai 2023

What is idea behind calling calling global operator delete from member operator delete?

In Qt's ExternalRefCountData (part of QSharedPtr implementation) https://codebrowser.dev/qt5/qtbase/src/corelib/tools/qsharedpointer_impl.h.html#159

I found code:

  inline void operator delete(void *ptr) { ::operator delete(ptr); }

What is purpose of this code?

I suppose without this line the things would be the same:

auto *d = new ExternalRefCountData;
delete d;//(2)

without ExternalRefCountData::operator delete line (2) should call ::operator delete(ptr); directly, so ExternalRefCountData::operator delete is useless? Or I missed something?

Aucun commentaire:

Enregistrer un commentaire