C++ (Qt)#include "adelegate.h" class A {public: void echo() {qDebug() << "A::echo()";}}; class Base {public: void foo() {qDebug() << "foo()";} void bar(int a) {qDebug() << QString("bar(%1)").arg(a);} A *test(QString a, int b) {qDebug() << QString("test(%1)").arg(a) << b; return new A;} }; int main(int argc, char *argv[]){Base b; typedef void(Base::*foo)();ADelegate<Base*, foo> delegate(&b, &Base::foo);delegate(); typedef void(Base::*bar)(int);ADelegate<Base*, bar, void, ALoki::TypeSequence<int> > delegate1(&b, &Base::bar);delegate1(2); typedef A*(Base::*test)(QString, int);ADelegate<Base*, test, A*, ALoki::TypeSequence<QString, int> > delegate2(&b, &Base::test);A *r = delegate2(QString("tratata"), 10);r->echo();delete r; return 0;}
C++ (Qt)#include "alokifunctor.h" void a() { qDebug() << "a()";} class Base {public: const QString test(const QString &txt) {return txt;}}; int main(int, char**){ALoki::Functor<> functor(&a);functor(); Base obj;typedef const QString(Base::*test)(const QString&);ALoki::Functor<const QString, ALoki::TypeSequence<const QString&> > functor1(&obj, &Base::test);qDebug() << functor1("tratata"); return 0;}
C++ (Qt)#include <iostream>#include <string>#include "signal_slot.h" void a() { std::cout << "a()" << std::endl;} class Base : public ssc::trackable {public: void test1() {std::cout << "test1()";} void test2(int a) {std::cout << a << std::endl;} void test3(const std::string &b) {std::cout << b << std::endl;} int problemFunc() { std::cout << "We are the champions!!!" << std::endl; return 0; } }; int main(){ ssc::signal<void> sig0; sig0.connect(a); sig0(); Base base; ssc::signal<int> sig_int; sig_int.connect(&base, &Base::test2); sig_int(10); ssc::signal<void> sig_problemFunc; sig_problemFunc.connect(&base, &Base::problemFunc); sig_problemFunc(); return 0;}