From 4e9231976e384add4ef068880814b4b133a146b2 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 22 Nov 2012 17:57:26 +0100 Subject: [PATCH] Unpack variadic arguments into QGenericArguments without boost::tuple. --- ext/libclementine-common/core/closure.cpp | 10 +------ ext/libclementine-common/core/closure.h | 34 ++++++++++------------- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/ext/libclementine-common/core/closure.cpp b/ext/libclementine-common/core/closure.cpp index d751f8b1d..eccc81ea7 100644 --- a/ext/libclementine-common/core/closure.cpp +++ b/ext/libclementine-common/core/closure.cpp @@ -48,15 +48,7 @@ void ObjectHelper::Invoked() { deleteLater(); } -template<> -void Arg>( - const boost::tuples::tuple<>&, - QList* list) {} - -template<> -void Arg( - const boost::tuples::null_type&, - QList* list) {} +void Unpack(QList*) {} } // namespace _detail diff --git a/ext/libclementine-common/core/closure.h b/ext/libclementine-common/core/closure.h index 351d926ab..59d05a7be 100644 --- a/ext/libclementine-common/core/closure.h +++ b/ext/libclementine-common/core/closure.h @@ -26,7 +26,6 @@ #include #include #include -#include namespace _detail { @@ -65,25 +64,21 @@ class ObjectHelper : public QObject { Q_DISABLE_COPY(ObjectHelper); }; -// Helper to unpack a tuple into a QList. -template -void Arg(const T& tail, QList* list) { - typedef decltype(tail.get_head()) HeadType; - list->append(Q_ARG(HeadType, tail.get_head())); - Arg(tail.get_tail(), list); +// Helpers for unpacking a variadic template list. + +// Base case of no arguments. +void Unpack(QList*); + +template +void Unpack(QList* list, const Arg& arg) { + list->append(Q_ARG(Arg, arg)); } -// Specialisation for starting with an empty tuple, ie. no arguments. -template<> -void Arg>( - const boost::tuples::tuple<>&, - QList* list); - -// Specialisation for the end of a tuple, where get_tail() returns null_type. -template<> -void Arg( - const boost::tuples::null_type&, - QList* list); +template +void Unpack(QList* list, const Head& head, const Tail&... tail) { + Unpack(list, head); + Unpack(list, tail...); +} template class Closure : public ClosureBase { @@ -111,9 +106,8 @@ class Closure : public ClosureBase { private: void Call(const Args&... args) { - auto t = boost::make_tuple(args...); QList arg_list; - Arg(t, &arg_list); + Unpack(&arg_list, args...); slot_.invoke( receiver_,