Boost function/bind problem

Discussion in 'C++' started by Fuzzy Coder, May 31, 2012.

  1. Fuzzy Coder

    Fuzzy Coder Guest

    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
    Fuzzy Coder, May 31, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Toby Bradshaw
    Replies:
    6
    Views:
    1,749
    Kai-Uwe Bux
    Jun 2, 2006
  2. Replies:
    4
    Views:
    422
  3. Replies:
    0
    Views:
    590
  4. Christopher
    Replies:
    1
    Views:
    810
    Yakov Gerlovin
    Oct 5, 2011
  5. Mark
    Replies:
    1
    Views:
    428
    Jeff Flinn
    Nov 25, 2012
Loading...

Share This Page