Boost and did you forget the ‘()’

Why when I use this m_Thread = boost::thread(boost::bind(&parallel::stop,this));
or this m_Thread = boost::thread(&parallel::stop,this);
I get invalid use of member function (did you forget the ‘()’ ?) on eclipse linux
Could you show more code?

The following works:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <boost/thread.hpp>
#include <iostream>

struct parallel {
    boost::thread m_Thread;
    void stop() { std::cout << "whatever this does\n"; }
    void start() {
        m_Thread = boost::thread(&parallel::stop,this);
    }
};
int main()
{
    parallel x;
    x.start();
    x.m_Thread.join();
    std::cout << "done\n";
}
    

live demo: http://coliru.stacked-crooked.com/a/3f93eb5997457b49
Topic archived. No new replies allowed.