title: C++11: std::thread inside a class executing a function member with thread initialisation in the constructor
body: <p>I'm trying to use std::thread from C++11. I couldn't find anywhere if it is possible to have a std::thread inside a class executing one of its function members. Consider the example below...
  In my try (below), the function is run().</p>
  
  <p>I compile with gcc-4.4 with -std=c++0x flag.</p>
  
  <pre><code>#ifndef RUNNABLE_H
  #define RUNNABLE_H
  
  #include &lt;thread&gt;
  
  class Runnable
  {
      public:
          Runnable() : m_stop(false) {m_thread = std::thread(Runnable::run,this); }
          virtual ~Runnable() { stop(); }
          void stop() { m_stop = false; m_thread.join(); }
      protected:
          virtual void run() = 0;
          bool m_stop;
      private:
          std::thread m_thread;
  };
  
  
  class myThread : public Runnable{
  protected:
      void run() { while(!m_stop){ /* do something... */ }; }
  };
  
  #endif // RUNNABLE_H
  </code></pre>
  
  <p>I'm getting this error and others: (same error with and without the $this)</p>
  
  <pre><code>Runnable.h|9|error: no matching function for call to ‘std::thread::thread(&lt;unresolved overloaded function type&gt;, Runnable* const)’|
  </code></pre>
  
  <p>When passing a pointer.</p>
  
  <pre><code>Runnable.h|9|error: ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function.  Say ‘&amp;Runnable::run’|
  </code></pre>