[Development] QtCS 2017 QtCore sessions
Jedrzej Nowacki
jedrzej.nowacki at qt.io
Wed Oct 18 10:00:23 CEST 2017
On wtorek, 17 października 2017 17:28:54 CEST Marc Mutz wrote:
> > (...)
> > Discussion not finished
>
> I certainly hope so, because the above does not make any sense. See my
> talk at QtWS. Returning QStringView is not different from c.begin() or
> str.data(). You need to document the lifetime of the data, that's it.
> (...)
As a person reading docs only if something is not working as expected, I'm
pondering, if there is a way to document the lifetime without documentation.
It seems that QStringView shares problems of raw pointers and raw pointers
issue was mostly solved by different smart pointers. So why not returning one
of these:
QViewValidAsLongAsObjectFoo<QStringView>
QViewValidUntilTheNextCall<QStringView>
QViewValidAsLongMoonIsTheRightPhase<QStringView>
Some of these could be enforced by asserts, some could be just for documenting
the issue. Anyway, just an idea :-)
Cheers,
Jędrek
More information about the Development
mailing list