QArrayDataOps: fix QList range ctors with mixed value_type in C++20 builds
The QList<X> range ctor is supposed to accept iterators with value_types convertible to X, e.g. tst_qitemselectionrange passes iterator to a container of QModelIndex to the ctor of a QList<QPersistentModelIndex>. But copyAppend() is not a template, so trying to pass QModelIndex* when QPersistentModelIndex* is expected errors out. Fix by taking the copyAppend() path only if the types match. Amends 507be11303c8dd9709d903f8e5ec197be66209ce. Change-Id: I5e3ff84a80dc05dafde5572463b33df9002c8fe0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
This commit is contained in:
parent
a07598e47b
commit
570485be95
@ -912,10 +912,17 @@ public:
|
||||
Q_UNUSED(distance);
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
if constexpr (
|
||||
std::is_convertible_v<
|
||||
constexpr bool canUseCopyAppend = std::conjunction_v<
|
||||
std::is_convertible<
|
||||
typename std::iterator_traits<It>::iterator_category,
|
||||
std::contiguous_iterator_tag>) {
|
||||
std::contiguous_iterator_tag
|
||||
>,
|
||||
std::is_same<
|
||||
std::remove_cv_t<typename std::iterator_traits<It>::value_type>,
|
||||
T
|
||||
>
|
||||
>;
|
||||
if constexpr (canUseCopyAppend) {
|
||||
this->copyAppend(std::to_address(b), std::to_address(e));
|
||||
} else
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user