Thread: Problem using boost::signals2

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    2

    Problem using boost::signals2

    Hello all,

    I'm using boost::signals2 on my application.

    When I try to make a connection between a signal and a slot, both taking the same arguments. I get a compilation error.

    I reduced the code to a mininum reproducible example:
    Code:
    #include <boost/signals2.hpp>
    class dest {
    public:
        dest() {}
        ~dest() {}
        
        void pslot(int *x , int i) {
            *x += i;
        }
    };
    
    class caller {
    private:
        dest *pd;
    public:
        caller() {}
        ~caller() { }
        
        boost::signals2::signal<void(int * , int)> sigEv;
        
        void init() {
            pd = new dest;
            sigEv.connect( boost::bind(&dest::pslot,pd) ); // <--- this line triggers the error
        }
        
    };
    This is the error I get, instantiated from the line that I indicate in the comment.

    target/usr/include/boost/bind/mem_fn.hpp:342: error: invalid use of non-static member function

    This is probably some silly error but I can't figure it out.

    Can anyone help me?
    Many thanks!
    --to

  2. #2

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    2
    Quote Originally Posted by Codeplug View Post
    Boost: bind.hpp documentation
    Tutorial

    I would try "boost::bind(&dest:slot, pd, _1, _2)"

    gg
    Thanks, that solved it!

    Cheers,
    --to

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM

Tags for this Thread