summaryrefslogtreecommitdiffstats
path: root/src/corelib/concurrent/qtconcurrentfunctionwrappers.h
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2011-08-26 15:43:06 +0200
committerQt by Nokia <qt-info@nokia.com>2011-09-17 03:21:15 +0200
commit0d4834c171f6c6c561fc5874010f71026ab56c18 (patch)
treebd582c60c142e967ee9e30f491c3f913227fd7ee /src/corelib/concurrent/qtconcurrentfunctionwrappers.h
parenta13b17e42a7ca146ec9503285df546d4ade22c91 (diff)
Wrap calls to Sequence::push_back
In C++11 push_back is overloaded to support rvalue-references, void std::vector<T>::push_back(const T &); void std::vector<T>::push_back(T &&); so attempting to get the address for push_back is ambiguous. Instead of hardcoding the function signature, the better and more general solution is to allow the compiler to do the required overload resolution itself, also allowing for implicit conversions to take place. Task-number: QTBUG-18996 Done-with: Liang Qi Reviewed-by: Olivier Goffart (cherry picked from commit ca34cc75294e0d2a8bc491a2c679fe8a69cd0408) Change-Id: Id271118e489f888905e491dd4cfc3d2db7697552 Reviewed-on: http://codereview.qt-project.org/4642 Reviewed-by: Liang Qi <liang.qi@nokia.com> Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Diffstat (limited to 'src/corelib/concurrent/qtconcurrentfunctionwrappers.h')
-rw-r--r--src/corelib/concurrent/qtconcurrentfunctionwrappers.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/corelib/concurrent/qtconcurrentfunctionwrappers.h b/src/corelib/concurrent/qtconcurrentfunctionwrappers.h
index 4bf2736e6c..1e09221cee 100644
--- a/src/corelib/concurrent/qtconcurrentfunctionwrappers.h
+++ b/src/corelib/concurrent/qtconcurrentfunctionwrappers.h
@@ -195,6 +195,25 @@ QtConcurrent::ConstMemberFunctionWrapper<T, C> createFunctionWrapper(T (C::*func
return QtConcurrent::ConstMemberFunctionWrapper<T, C>(func);
}
+struct PushBackWrapper
+{
+ typedef void result_type;
+
+ template <class C, class U>
+ inline void operator()(C &c, const U &u) const
+ {
+ return c.push_back(u);
+ }
+
+#ifdef Q_COMPILER_RVALUE_REFS
+ template <class C, class U>
+ inline void operator()(C &c, U &&u) const
+ {
+ return c.push_back(u);
+ }
+#endif
+};
+
template <typename Functor, bool foo = HasResultType<Functor>::Value>
struct LazyResultType { typedef typename Functor::result_type Type; };
template <typename Functor>