diff options
author | Marc Mutz <marc.mutz@qt.io> | 2024-01-24 11:36:35 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2024-01-26 23:50:57 +0100 |
commit | 94e122c594a3697b98dcc99a9e332b0f5e816d2d (patch) | |
tree | d549ddc4ec6e20a1ca8c3012c0ebd52aacf894ec /tests/auto/corelib/tools | |
parent | c92de95bedcd6f3487b254f37270e207ee7b9894 (diff) |
QSpan: make adl_begin() etc SFINAE-friendly
The definition of iterator_t, and, therefore, of is_compatible_range
depends on this, otherwise say, 0, is being treated as a valid range
and hits a hard error in adl_begin() when trying to call begin(int&).
TIL: decltype(auto) does _not_ SFINAE.
Fix by calculating the return type manually, re-enabing SFINAE.
Pick-to: 6.7 6.6
Change-Id: Icacd70554f4050ecaeb396c9ae60bc4f21a220c9
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests/auto/corelib/tools')
-rw-r--r-- | tests/auto/corelib/tools/qspan/tst_qspan.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qspan/tst_qspan.cpp b/tests/auto/corelib/tools/qspan/tst_qspan.cpp index d994484c7b..c1bd780cb6 100644 --- a/tests/auto/corelib/tools/qspan/tst_qspan.cpp +++ b/tests/auto/corelib/tools/qspan/tst_qspan.cpp @@ -96,6 +96,9 @@ static_assert(!std::is_convertible_v<QSpan<const int, 42>, std::span<int, 42>>); static_assert(!std::is_convertible_v<QSpan<const int, 0>, std::span<int, 0>>); #endif // __cpp_lib_span +// Spans don't convert from nonsense: +static_assert(!std::is_constructible_v<QSpan<const int>, int&&>); + class tst_QSpan : public QObject { Q_OBJECT |