Hi Marc,
On 11.11.22 09:35, Ulf Hermann via Development wrote:
There is an undeniable benefit of _offering_ QSpan, QStringView, and
generator APIs in a few relevant cases:
1. Users want to pass a "foreign" container to a Qt function that
doesn't only store it as QList or QString. It might merely iterate it or
store it as something else.
The assumption that there's a problem only for "foreign containers" is
incorrect: Take the native Qt container QString as an example. See
assembly in my QAnyStringView blog post:
https://www.qt.io/blog/qstringview-diaries-qanystringview You have this
problem as soon as you pass constant data, which is a common enough
use-case to warrant optimizing for.
My point is the "doesn't only store it as QList or QString" and
"foreign" is in quotes quite on purpose. Maybe that wasn't clear enough,
though.
So, if the method immediately converts whatever it gets to QList or
QString, then there is no point in passing it a span or view. Otherwise,
since we don't know what people are going to do with the method (pass
foreign containers, subsets, etc), a span or view may be adequate.
br,
Ulf
_______________________________________________
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development