[Development] QList

Marc Mutz marc.mutz at kdab.com
Sat Mar 18 22:33:32 CET 2017

On Saturday 18 March 2017 19:30:35 Thiago Macieira wrote:
> class QStringView               - has all the const functions
> class QString : public QStringView      - adds the mutating functions
> class QtExclusive::QString : public QString

No inheritance. These things have no is-a relationship whatsoever.

Example: QString cannot inherit QStringView because QStringView::trimmed() 
returns a QStringView while QString::trimmed() needs to return a QString. 
These return values aren't covariant, either, because a) they're not pointers, 
so C++ doesn't let you, b) the functions aren't virtual so C++ won't let you 
and c) the QStringView implementation has no idea how to manage QString's 


Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt, C++ and OpenGL Experts

More information about the Development mailing list