[Development] Don't use Private *d when your class is immutable

Thiago Macieira thiago.macieira at intel.com
Fri Mar 3 16:11:54 CET 2017

Em sexta-feira, 3 de março de 2017, às 03:19:42 PST, Marc Mutz escreveu:
> The simplest implementation of an immutable class that cannot or should not
> contain all state inline (like QRect) is an int +
> Q_GLOBAL_STATIC(Container). If you put all init code into the ctor of the
> Container class, then you get thread-saftey for free, too. Only if you want
> to add entries dynamically you need to think about threading. And all the
> special member functions come for free, too, fully optimal (nothrow,
> inline).

Sorry, no.

If you need to have a global static to store information, then it sounds 
wrong. I agree we should use ints, enums and opaque pointers when wrapping a 
third-party API that is like that. If they have a global table, that's their 

But we should not add more global tables.

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

More information about the Development mailing list