On Saturday 17 October 2015 01:18:06 Marc Mutz wrote: > If you need a real-world example of where QStringView would be handy: Some > 3rd-party code returns you a char16_t *path, and you want to perform a > QDir::cd(). Currently, you need to create a QString (which allocates). Had > QDir::cd() taken a QStringView, you wouldn't have that allocation.
Bad example. You can use QString::fromRawData. While that today allocates the d pointer, for Qt 6 it wouldn't (null d pointer) and there would be no code change for the user. There is, however, the danger of fromRawData: you need to be sure the called function won't try to store the QString. With a QStringView or the unsharable QString that Brano proposed in the other email, it would be clear that a deep copy needs to happen. -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development