Boost logo

Boost Users :

Subject: [Boost-users] Boost.Coroutine + objects
From: Van Pers (vanpersvan_at_[hidden])
Date: 2013-10-01 19:19:42


Hello guys, I am using Boost Coroutines but I would like to use them in a Objected-Oriented way. So, I  tried to rewrite parallel.cpp (boost/libs/coroutine/example) using the example functions like class methods, but it did not work. This is my code, anybody can help me? My code: typedef boost::coroutines::coroutine< void() > coroutine_t; class Abc{  public:  void first( coroutine_t::caller_type & self)  {      std::cout << "started first! ";      for ( int i = 0; i < 10; ++i)      {   self();   std::cout << "a" << i;      }  }    void second( coroutine_t::caller_type & self)  {      std::cout << "started second! ";      for ( int i = 0; i < 10; ++i)      {   self();   std::cout << "b" << i;      }  }  void third(){ coroutine_t c1( boost::bind( first, _1) ); coroutine_t c2( boost::bind( second, _1) );   while ( c1 && c2) {       c1();       std::cout << " ";       c2();       std::cout << " ";   }  }  }; int main( int argc, char * argv[]) { Abc* myabc = new Abc(); myabc->third();     std::cout << "\nDone" << std::endl;     return EXIT_SUCCESS; } Thank you, Van



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net