Problem using boost::signals2

This is a discussion on Problem using boost::signals2 within the C++ Programming forums, part of the General Programming Boards category; Hello all, I'm using boost::signals2 on my application. When I try to make a connection between a signal and a ...

  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, 05: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, 09:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 03:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21