language: C++ 4.7.2 (gcc-4.7.2)
date: 573 days 7 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <boost/signals2.hpp>
 
class My
{
private:
    boost::signals2::signal<void (int)> sig;
 
public:
    template < typename F, typename T, typename A1 >
    void proxy( F f, T t, A1 a1 )
    {
        boost::bind( f, t, a1 );    // this gets messaged elsewhere
    }
 
    int foo( int i )
    {
        return i-1;
    }
 
    int bar( int i )
    {
        return i+1;
    }
 
    template < typename F, typename T, typename A1 >
    boost::signals2::connection connect( F f, T t, A1 a1 )
    {
        return sig.connect( boost::bind( &My::proxy< F, T, int >, t, f, t, a1 ) );
        //                                                 ^^^
        //                                                 here
    }
 
    void init()
    {
        boost::signals2::connection c1 = connect( &My::foo, this, 11 );
        boost::signals2::connection c2 = connect( &My::bar, this, _1 );
    }
};
 
int main() {
    My().init();
}