Boost logo

Boost :

From: Tomasz Kowalczyk (tomek_at_[hidden])
Date: 2000-04-08 01:45:53


Wow ! I have just tried to use signals with binders from the lambda
library.
Works great !

LL is so cool :) !

Tomek

//////////////////////////////////////////////////////////////////////
#include <signals.h>
#include <ll/ll.hpp>
#include <iostream>

using namespace boost;

struct A {
    void f(int a) { cout << "A::f(" << a << ")" << endl; }
};

struct B {
    int g(int a) { cout << "B::g(" << a << ")" << endl; }
};

void f(int a) { cout << "f(" << a << ")" << endl; }
void g(int a, int b) { cout << "g(" << a << "," << b << ")" << endl; }

main()
{
    A a;
    B b;

    signal<int> sig;

    sig.connect( cout << free1 << "\n" );
    sig.connect( bind( &f, free1 ) );
    sig.connect( bind( &a.f, a, 2.0 * free1 ) );
    sig.connect( bind( &b.g, b, -free1 ) );

    sig(5);

    cout << "---" << endl;

    signal<int,int> sig2;

    sig2.connect( bind( &f, free2 ) );
    sig2.connect( bind( &f, free1 + free2 ) );
    sig2.connect( bind( &a.f, a, 2 * (free1 - free2) ) );
    sig2.connect( bind( &g, free2, 3 ) );

    sig2(15,16);

    return 0;
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk