summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSona Kurazyan <[email protected]>2020-10-12 14:24:07 +0200
committerSona Kurazyan <[email protected]>2020-10-13 09:49:51 +0200
commitd5c53554e5d71e3518a446b634428bb66fc369fd (patch)
tree2efbf0d703fa400f6ef20e8bee4e8a7d690a0ac7
parent1918c689d78b0f6a718343e7ebceb387acc32a97 (diff)
Loosen the requirements on the container passed to QtConcurrent::map*
Using std::begin() and std::end() forces the user to have const begin() and end() member functions being defined for the passed container. This is because std::declval<T>() returns rvalue which forces the compiler to select std::{begin, end}()(const Container &c) overloads and an test for a presence of const {begin, end}() methods. Change-Id: I9d96d9f73891ece53224f1741a1334500f7b35ad Reviewed-by: Andrei Golubev <[email protected]> Reviewed-by: MÃ¥rten Nordheim <[email protected]>
-rw-r--r--src/concurrent/qtconcurrentcompilertest.h4
-rw-r--r--src/concurrent/qtconcurrentfunctionwrappers.h2
-rw-r--r--tests/auto/concurrent/qtconcurrentmap/functions.h2
3 files changed, 3 insertions, 5 deletions
diff --git a/src/concurrent/qtconcurrentcompilertest.h b/src/concurrent/qtconcurrentcompilertest.h
index 8292d5c5045..a5456f8d279 100644
--- a/src/concurrent/qtconcurrentcompilertest.h
+++ b/src/concurrent/qtconcurrentcompilertest.h
@@ -51,8 +51,8 @@ namespace QtPrivate {
template <class T, typename = void>
struct IsIterable : std::false_type {};
template <class T>
- struct IsIterable<T, std::void_t<decltype(std::begin(std::declval<T>())),
- decltype(std::end(std::declval<T>()))>>
+ struct IsIterable<T, std::void_t<decltype(std::declval<T>().begin()),
+ decltype(std::declval<T>().end())>>
: std::true_type
{ };
diff --git a/src/concurrent/qtconcurrentfunctionwrappers.h b/src/concurrent/qtconcurrentfunctionwrappers.h
index bb78ea99537..be954167598 100644
--- a/src/concurrent/qtconcurrentfunctionwrappers.h
+++ b/src/concurrent/qtconcurrentfunctionwrappers.h
@@ -77,7 +77,7 @@ struct Argument
template <class Sequence>
struct Argument<Sequence, typename std::enable_if<IsIterableValue<Sequence>>::type>
{
- using Type = std::decay_t<decltype(*std::begin(std::declval<Sequence>()))>;
+ using Type = std::decay_t<decltype(*std::declval<Sequence>().begin())>;
};
template <class Iterator>
diff --git a/tests/auto/concurrent/qtconcurrentmap/functions.h b/tests/auto/concurrent/qtconcurrentmap/functions.h
index e5090ef03e8..aeba7949774 100644
--- a/tests/auto/concurrent/qtconcurrentmap/functions.h
+++ b/tests/auto/concurrent/qtconcurrentmap/functions.h
@@ -159,8 +159,6 @@ public:
const_iterator cend() const { return data.cend(); }
iterator begin() { return data.begin(); }
iterator end() { return data.end(); }
- const_iterator begin() const { return data.cbegin(); }
- const_iterator end() const { return data.cend(); }
bool operator==(const MoveOnlyVector &other) const { return data == other.data; }
private: