On sábado, 25 de março de 2017 00:57:57 PDT Marc Mutz wrote: > On 2017-03-24 20:55, Thiago Macieira wrote: > > Em sexta-feira, 24 de março de 2017, às 09:18:05 PDT, Marc Mutz > > > > escreveu: > >> > Are you of the opinion that private inheritance has no purpose and > >> > should > >> > never be used? > >> > >> No, and if you look at code I have written over the years, you will > >> see that > >> I do use it. > >> > >> One thing I've looked into in the past is this: Q6Polygon should > >> inherit a > >> Q6VectorBase<QPoint> that also Q6Vector<QPoint> inherits. This will > >> allow > >> easy specialisation of QVector<T*> by inheriting QBasicVector<const > >> void*>. > > > > Can you elaborate on your thinking? What's QBasicVector and what's > > QVector? > > QBasicVector (or QVectorBase, or ...) is QVector with protection against > using it as-is (e.g. protected dtor). QVector inherits QBasicVector to > lift the restriction. This inheritance may even be public to avoid lots > of using QBasicVector::foo; This is ok, because QBasicVector is not > usable as-is, but I'd still make it private, because when you start to > inherit to specialise (QVector<T*> : QBasicVector<const void*>), you > don't want the void* methods to leak. > > So, if you absolutely are set on inheritance, then use the same pattern. > But I don't see this here. None of the points that makes this a good > idea for QVector (or QVLA) pertains to QString: we don't need to fight > template bloat, we don't have multiple classes inheriting QStringView...
And what are the points that make QBasicVector good? If QBasicVector is not usable as-is, then it must be useful because it's sharing code between QVector and something else. What is that something else? Note that I think we should change QPolygon to stop inheriting from QVector in the first place. QPolygon is not a QVector. -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
