From c4de095be1fb9dbf3d7fc684f6978929a3d6b018 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 8 Feb 2024 11:38:33 +0100 Subject: [PATCH] QSpan: apply LWG 3346 work-around We have not hit the GCC < 10.4 problem with containers that define both element_type and value_type, yet, but we have with QVersionNumber, so proactively apply it to QSpan, too. While we're at it, copy the QList code to mark QSpan, too, as contiguous. Pick-to: 6.6 Change-Id: I883fd0b5f75db175a730262035ebbf0cb19de529 Reviewed-by: Allan Sandfeld Jensen (cherry picked from commit 95feea933bbc67ab4a188470973da3f4df450c3d) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/tools/qspan.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/corelib/tools/qspan.h b/src/corelib/tools/qspan.h index f72329d9d5f..e8aa8f3254f 100644 --- a/src/corelib/tools/qspan.h +++ b/src/corelib/tools/qspan.h @@ -316,14 +316,17 @@ class QSpan static constexpr bool subspan_always_succeeds_v = N <= E && E != q20::dynamic_extent; public: // constants and types + using value_type = std::remove_cv_t; +#ifdef QT_COMPILER_HAS_LWG3346 + using iterator_concept = std::contiguous_iterator_tag; using element_type = T; - using value_type = std::remove_cv_t; +#endif using size_type = qsizetype; // difference to std::span using difference_type = qptrdiff; // difference to std::span - using pointer = element_type*; - using const_pointer = const element_type*; - using reference = element_type&; - using const_reference = const element_type&; + using pointer = T*; + using const_pointer = const T*; + using reference = T&; + using const_reference = const T&; using iterator = pointer; // implementation-defined choice using const_iterator = const_pointer; // implementation-defined choice using reverse_iterator = std::reverse_iterator;