From 5656a60dd067a69f9e864a33068ec300124d4e05 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 15 Apr 2021 16:10:12 +0200 Subject: [PATCH] QList::(const_)iterator: protect element_type on GCC < 11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 10 in C++20 mode will still try to use std::indirectly_readable_traits on QList iterators, and since it does not have the fixes for LWG 3346 / 3541, it will fail to build: /usr/include/c++/10/bits/iterator_concepts.h: In substitution of ‘template using __iter_value_t = typename std::__detail::__iter_traits_impl<_Tp, std::indirectly_readable_traits<_Iter> >::type::value_type [with _Tp = QList >::const_iterator]’: /usr/include/c++/10/bits/iterator_concepts.h:248:11: required by substitution of ‘template using iter_value_t = std::__detail::__iter_value_t::type>::type> [with _Tp = QList >::const_iterator]’ /usr/include/c++/10/bits/iterator_concepts.h:468:11: required from ‘class std::reverse_iterator >::const_iterator>’ ../src/corelib/itemmodels/qsortfilterproxymodel.cpp:669:43: required from here /usr/include/c++/10/bits/iterator_concepts.h:243:13: error: ambiguous template instantiation for ‘struct std::indirectly_readable_traits >::const_iterator>’ 243 | using __iter_value_t = typename | ^~~~~~~~~~~~~~ /usr/include/c++/10/bits/iterator_concepts.h:231:12: note: candidates are: ‘template requires requires{typename _Tp::value_type;} struct std::indirectly_readable_traits<_Iter> [with _Tp = QList >::const_iterator]’ 231 | struct indirectly_readable_traits<_Tp> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/10/bits/iterator_concepts.h:236:12: note: ‘template requires requires{typename _Tp::element_type;} struct std::indirectly_readable_traits<_Iter> [with _Tp = QList >::const_iterator]’ 236 | struct indirectly_readable_traits<_Tp> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ So hide element_type as well. The CI didn't catch this because the CI doesn't build in C++20 mode. Amends 595b4e1a9b4. Change-Id: I5c8e47d693ca584571cd89f856d08ba249dd05ab Reviewed-by: Fabian Kosmale --- src/corelib/tools/qlist.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 61a02f795ba..6aafb86c01e 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -137,10 +137,10 @@ public: // libstdc++ shipped with gcc < 11 does not have a fix for defect LWG 3346 #if __cplusplus >= 202002L && (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE >= 11) using iterator_category = std::contiguous_iterator_tag; + using element_type = value_type; #else using iterator_category = std::random_access_iterator_tag; #endif - using element_type = value_type; using pointer = T *; using reference = T &; @@ -179,10 +179,10 @@ public: // libstdc++ shipped with gcc < 11 does not have a fix for defect LWG 3346 #if __cplusplus >= 202002L && (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE >= 11) using iterator_category = std::contiguous_iterator_tag; + using element_type = const value_type; #else using iterator_category = std::random_access_iterator_tag; #endif - using element_type = const value_type; using pointer = const T *; using reference = const T &;