Boost Users :
Subject: Re: [Boost-users] Boost.Coroutine and Object Inheritance
From: Nat Goodspeed (nat_at_[hidden])
Date: 2013-12-19 08:55:58
On Thu, Dec 19, 2013 at 5:51 AM, Carlos Ferreira <carlosmf.pt_at_[hidden]>wrote:
I wanted to use the coroutines as objects and for that, I tried to build a
> simple object and inherit the boost::coroutines::coroutine template.
> Is this right? Can I actually inherit from
> the boost::coroutines::coroutine template ?
> If yes, how can I proceed from here, to use the run() object method as the
> coroutine itself, with an io_service provided through the constructor ?
Um. It's much more typical to instantiate a coroutine, passing it the code
you want to run. That can be an object method, run() or whatever: use
boost::bind() to bind the object pointer/reference to the method, along
with any other parameters you want to pass it initially.
I would have to let Oliver respond to the question about whether it's
acceptable to derive from the coroutine template. But I claim that it will
perplex future maintainers.
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