Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Boost function/bind problem

11 views
Skip to first unread message

Fuzzy Coder

unread,
May 31, 2012, 3:44:47 PM5/31/12
to
Hello there.
I am trying to use the Boost function type in conjunction with bind, in
order to
homogenise some code.


class C1
{
public:

void
someOp(int i, float f) { /* ... */ } ;

}

class C2
{
public:

void
otherOp(int i, float f) { /* ... */ } ;

}


main()
{
typedef boost::function<void (int, float) > F ;
F func[2] ;

C1 c1 ;
C2 c2 ;

I want to use boost::bind to do the following abstract functions :

f[0] = lambda(int i, float f) : c1.someOp(i,f) ;
f[1] = lambda(int i, float f) : c2.otherOp(i,f) ;


I have achieved the above when the ops on C1/C2 only have one input
argument (op(int) etc) . But when I try functions with more than one
argument, my attempts fail when I use boost::bind.

If anyone can show how f[0] and f[1] would be defined using boost::bind
etc, it would be much appreciated.


Thanks in advance

0 new messages