On 18/07/2026 19:41, Thiago Macieira wrote:
If the class is using a smart pointer for the Private, the smart pointer will propagate the constness of the public function and it will be easy to notice where we violate by way of a const_cast. Older classes often use raw pointers, which don't propagate const, and then we may perform non-const operations, intentionally or not.
For QMap I introduced QESDPV2 precisely because I wanted deep constness. Neither QESDP nor the standard library smart pointers propagate, and those are landmines. We should likely also introduce a private propagate_const if someone really needs a raw pointer for whatever reason.
This is also documented as THICK.8 in https://codereview.qt-project.org/c/meta/quips/+/321050(I also ported uic to generate propagate_const<> around the QWidget* data members in the ui class, catching many logical constness bugs in some projects.)
My 2 c, -- Giuseppe D'Angelo | [email protected] | Senior Software Engineer KDAB (France) S.A.S., a KDAB Group company Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com KDAB - Trusted Software Excellence
smime.p7s
Description: S/MIME Cryptographic Signature
-- Development mailing list [email protected] https://lists.qt-project.org/listinfo/development
