qt6-bb10/tests/auto/corelib/tools
Giuseppe D'Angelo 7f7b5ff3a1 QSpan: add construction from initializer_list
P2447 has been merged in C++26, backport the same functionality.

This makes QSpan<const T> a proper replacement for a const QList<T>&
parameter, because now both can be built via a braced-init-list.

  // void f(const QList<int> &l); // old
  void f(QSpan<const int>);       // new

  f({1, 2, 3});                   // now OK

This is, technically speaking, SiC: in the presence of both `f`
overloads, the code above would have called the QList one. Now instead
the call is ambiguous.

We've been there already -- this is QString and QStringView all over
again, and the solution is the same: get rid of the owning container
overload. I'd rather have this construction *sooner* rather than *later*
in order to minimize the fallout.

And just like QString vs QStringView, there's nothing really doable to
prevent instant-dangling situations:

  QStringView v = getString();    // dangles
  QSpan<const int> s = {1, 2, 3}; // ditto

except for using QSpan (QStringView) as a *parameter type only*.

Note that QSpan with dynamic extent was already convertible from
std::initializer_list through its ranged constructor. However this fact
alone doesn't unlock the above syntax. QSpan with a static extent was
also convertible for the same reason. (This is non-standard:
std::span's range constructor for static extents is explicit, but QSpan
doesn't follow that design choice and makes the constructors implicit
instead.)

Found in API-review.

Pick-to: 6.7
Change-Id: I160ab5b292b0c2568cd9a7ad1b4430085f475c29
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2024-03-06 08:44:46 +00:00
..
collections Remove extra semi-colons 2024-02-06 20:17:18 +09:00
containerapisymmetry Change license for tests files 2024-02-04 09:56:42 +01:00
qalgorithms Change license for tests files 2024-02-04 09:56:42 +01:00
qarraydata Change license for tests files 2024-02-04 09:56:42 +01:00
qatomicscopedvaluerollback Change license for tests files 2024-02-04 09:56:42 +01:00
qbitarray Change license for tests files 2024-02-04 09:56:42 +01:00
qcache Change license for tests files 2024-02-04 09:56:42 +01:00
qcommandlineparser Change license for tests files 2024-02-04 09:56:42 +01:00
qcontiguouscache Change license for tests files 2024-02-04 09:56:42 +01:00
qcryptographichash Change license for tests files 2024-02-04 09:56:42 +01:00
qduplicatetracker Change license for tests files 2024-02-04 09:56:42 +01:00
qeasingcurve Change license for tests files 2024-02-04 09:56:42 +01:00
qexplicitlyshareddatapointer Change license for tests files 2024-02-04 09:56:42 +01:00
qflatmap Change license for tests files 2024-02-04 09:56:42 +01:00
qfreelist Change license for tests files 2024-02-04 09:56:42 +01:00
qhash Change license for tests files 2024-02-04 09:56:42 +01:00
qhashfunctions qHash: backport the q(u)int128-to-quint64 reduction trick to 32-bit 2024-02-12 17:01:33 -08:00
qhashseed Change license for tests files 2024-02-04 09:56:42 +01:00
qline Change license for tests files 2024-02-04 09:56:42 +01:00
qlist QList: add uninitialized resizes 2024-02-16 14:20:50 +01:00
qmacautoreleasepool Change license for tests files 2024-02-04 09:56:42 +01:00
qmakearray Change license for tests files 2024-02-04 09:56:42 +01:00
qmap QMap: add missing qHash() overload 2024-02-09 20:33:05 +00:00
qmargins Change license for tests files 2024-02-04 09:56:42 +01:00
qmessageauthenticationcode Change license for tests files 2024-02-04 09:56:42 +01:00
qoffsetstringarray Change license for tests files 2024-02-04 09:56:42 +01:00
qpair Change license for tests files 2024-02-04 09:56:42 +01:00
qpoint Change license for tests files 2024-02-04 09:56:42 +01:00
qpointf Change license for tests files 2024-02-04 09:56:42 +01:00
qqueue Change license for tests files 2024-02-04 09:56:42 +01:00
qrect Change license for tests files 2024-02-04 09:56:42 +01:00
qringbuffer Change license for tests files 2024-02-04 09:56:42 +01:00
qscopedpointer Change license for tests files 2024-02-04 09:56:42 +01:00
qscopedvaluerollback Change license for tests files 2024-02-04 09:56:42 +01:00
qscopeguard Change license for tests files 2024-02-04 09:56:42 +01:00
qset Change license for tests files 2024-02-04 09:56:42 +01:00
qsharedpointer Change license for tests files 2024-02-04 09:56:42 +01:00
qsize Change license for tests files 2024-02-04 09:56:42 +01:00
qsizef Change license for tests files 2024-02-04 09:56:42 +01:00
qspan QSpan: add construction from initializer_list 2024-03-06 08:44:46 +00:00
qstl Change license for tests files 2024-02-04 09:56:42 +01:00
qtaggedpointer Change license for tests files 2024-02-04 09:56:42 +01:00
qtimeline Change license for tests files 2024-02-04 09:56:42 +01:00
qtyperevision Change license for tests files 2024-02-04 09:56:42 +01:00
quniquehandle Change license for tests files 2024-02-04 09:56:42 +01:00
qvarlengtharray QVarLengthArray: re-publish Prealloc as a nested PreallocatedSize 2024-02-15 17:44:36 +00:00
qversionnumber Change license for tests files 2024-02-04 09:56:42 +01:00
CMakeLists.txt Dissociate QTypeRevision from QVersionNumber 2024-01-10 02:25:24 +00:00