[Development] final value classes: some background information and plans

Oswald Buddenhagen oswald.buddenhagen at nokia.com
Wed Mar 7 18:14:20 CET 2012


On Wed, Mar 07, 2012 at 08:57:03AM +0100, ext Marc Mutz wrote:
> I've uploaded a patch series that makes most of the value classes in QtCore 
> final in the C++11 sense (ie. under a C++11 compiler, these can no longer be 
> inherited from).
> 
-1

> Value classes are meant to be be used as-is. When they are subclassed, that 
> usually indicates laziness on the side of the programmer in the best case, 
> and a deep misunderstanding of C++' class model in the worst case.
>
inheriting from value types is just fine if you change only behavior
(e.g., the hashing function or the comparison operators). using
delegates for every imaginable function instead just adds an amazing
amount of noise. this can be already seen in some of your patches. not
wanting that is not being lazy, but sane.

> In the next step, this would allow QList to select the most efficient
> backend to use (QBasicList or QBasicVector), depending on the
> QTypeInfo traits. This would deal with the inefficiencies surrounding
> QList<T> where sizeof(T) != sizeof(void*) or T isn't movable in a SC
> way.
> 
why can't you just make qlist more vector-like (using T* instead of T
only for complex types and types explicitly declared as large)? this has
been discussed before and is only lacking someone to actually implement
it.




More information about the Development mailing list