[Development] QList

Martin Smith Martin.Smith at qt.io
Sat Mar 25 17:11:48 CET 2017


>Note that I think we should change QPolygon to stop inheriting from QVector in

>the first place. QPolygon is not a QVector.


But then a vector is not a collection.

________________________________
From: Development <development-bounces+martin.smith=qt.io at qt-project.org> on behalf of Thiago Macieira <thiago.macieira at intel.com>
Sent: Saturday, March 25, 2017 4:29:09 PM
To: development at qt-project.org
Subject: Re: [Development] QList

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
Development at qt-project.org
http://lists.qt-project.org/mailman/listinfo/development
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20170325/491435d8/attachment.html>


More information about the Development mailing list