On Sat, Mar 18, 2017 at 11:30:35AM -0700, Thiago Macieira wrote:
> Em sábado, 18 de março de 2017, às 05:54:20 PDT, André Pönitz escreveu:
> > Aliasing QList to QVector might be a feasible option, or maybe replacing
> > QList implementation by QVector's, and replacing QVector by something
> > not reference-counted.
> 
> My plan (which is still not discussed properly and not proven to be feasible) 
> is to provide both referece-counted and non-counted versions of QVector, 
> QString and QByteArray.
> 
> QVector (and, in fact, all the containers) is easy because it's a template in 
> the first place. Performing std::move from QtExclusive::QVector (name to be 
> discussed) to QVector transfers the array and starts the reference counting; 
> std::move in the other direction also transfers if the reference count is 
> still 1, copying otherwise. That allows code like:
> 
> QVector<MyType> someFunction()        // out-of-line
> {
>       QtExclusive::QVector<MyType> vector;
>       [ operate and populate vector ]
>       return vector;          // automatic move
> }
> 
> in user code:
>       QtExclusive::QVector<MyType> vector = someFunction();   // automatic 
> move
>       [ mutate some more ]
> 
> The objecitve is that the mutating code in [] above runs without having the 
> compiler generate superfluous checks for the reference count which we know to 
> be 1 and emit dead code for the detach() function.

That would pretty much address the biggest issues I currently have with
QVector.

Andre'
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to