Use boost function for compatibility

This commit is contained in:
John Maguire 2013-11-22 11:53:47 +00:00
parent b17b075361
commit cc43e339c1
3 changed files with 9 additions and 7 deletions

View File

@ -33,7 +33,7 @@ ClosureBase::~ClosureBase() {
CallbackClosure::CallbackClosure(
QObject* sender,
const char* signal,
std::function<void()> callback)
boost::function<void()> callback)
: ClosureBase(new ObjectHelper(sender, signal, this)),
callback_(callback) {
}
@ -67,7 +67,7 @@ void Unpack(QList<QGenericArgument>*) {}
_detail::ClosureBase* NewClosure(
QObject* sender,
const char* signal,
std::function<void()> callback) {
boost::function<void()> callback) {
return new _detail::CallbackClosure(
sender, signal, callback);
}

View File

@ -158,12 +158,12 @@ class CallbackClosure : public ClosureBase {
CallbackClosure(
QObject* sender,
const char* signal,
std::function<void()> callback);
boost::function<void()> callback);
virtual void Invoke();
private:
std::function<void()> callback_;
boost::function<void()> callback_;
};
} // namespace _detail
@ -194,13 +194,13 @@ _detail::ClosureBase* NewClosure(
_detail::ClosureBase* NewClosure(
QObject* sender,
const char* signal,
std::function<void()> callback);
boost::function<void()> callback);
template <typename... Args>
_detail::ClosureBase* NewClosure(
QObject* sender,
const char* signal,
std::function<void(Args...)> callback,
boost::function<void(Args...)> callback,
const Args&... args) {
return NewClosure(sender, signal, boost::bind(callback, args...));
}

View File

@ -5,6 +5,8 @@
#include <QSharedPointer>
#include <QSignalSpy>
#include <boost/function.hpp>
#include "config.h"
#include "core/closure.h"
#include "test_utils.h"
@ -92,7 +94,7 @@ TEST(ClosureTest, ClosureWorksWithStandardFunctions) {
bool called = false;
int question = 42;
int answer = 0;
std::tr1::function<void(bool*,int,int*)> callback(&Foo);
boost::function<void(bool*,int,int*)> callback(&Foo);
NewClosure(
&sender, SIGNAL(Emitted()),
callback, &called, question, &answer);