summaryrefslogtreecommitdiffstats
path: root/tests/auto/concurrent/testhelper_functions.h
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2020-10-09 18:21:17 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2020-10-30 17:19:26 +0100
commit4d9658b7cd2b072dd8b24d9bb6844b7cbcf22ad0 (patch)
treeab43ab1986e351468b3f099ee1b02752e4479f81 /tests/auto/concurrent/testhelper_functions.h
parentff0ba7e2d7b91fd5809cb314935a1ca1a436f6c9 (diff)
Use universal references for passing callables in QtConcurrent
Task-number: QTBUG-87596 Change-Id: I219f08d73b97317820ec6e329ab1e6c89c0545f1 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests/auto/concurrent/testhelper_functions.h')
-rw-r--r--tests/auto/concurrent/testhelper_functions.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/concurrent/testhelper_functions.h b/tests/auto/concurrent/testhelper_functions.h
index aeba794977..17836cba51 100644
--- a/tests/auto/concurrent/testhelper_functions.h
+++ b/tests/auto/concurrent/testhelper_functions.h
@@ -44,6 +44,19 @@ public:
}
};
+class KeepEvenIntegersMoveOnly
+{
+public:
+ KeepEvenIntegersMoveOnly() = default;
+ KeepEvenIntegersMoveOnly(KeepEvenIntegersMoveOnly &&) = default;
+ KeepEvenIntegersMoveOnly &operator=(KeepEvenIntegersMoveOnly &&other) = default;
+
+ KeepEvenIntegersMoveOnly(const KeepEvenIntegersMoveOnly &) = delete;
+ KeepEvenIntegersMoveOnly &operator=(const KeepEvenIntegersMoveOnly &) = delete;
+
+ bool operator()(int x) { return (x & 1) == 0; }
+};
+
class Number
{
int n;
@@ -121,6 +134,19 @@ public:
}
};
+class IntSumReduceMoveOnly
+{
+public:
+ IntSumReduceMoveOnly() = default;
+ IntSumReduceMoveOnly(IntSumReduceMoveOnly &&) = default;
+ IntSumReduceMoveOnly &operator=(IntSumReduceMoveOnly &&other) = default;
+
+ IntSumReduceMoveOnly(const IntSumReduceMoveOnly &) = delete;
+ IntSumReduceMoveOnly &operator=(const IntSumReduceMoveOnly &) = delete;
+
+ void operator()(int &sum, int x) { sum += x; }
+};
+
void numberSumReduce(int &sum, const Number &x)
{
sum += x.toInt();