Boost logo

Boost Users :

Subject: Re: [Boost-users] [thread] About the virtual in virtual operator()
From: Nigel Rantor (wiggly_at_[hidden])
Date: 2009-10-30 11:46:14


Richard Vock wrote:
> I don't really know wether this is a Boost.Thread related
> question or a general c++ related, but since I couldn't
> decide I will disturb you first ;)
>
> If I replace 27 by 28+29 I (expectedly) get a compile error
> since Kernel is abstract. However if I make it non-abstract
> by implementing the operator() in it, it is this function
> (namely Kernel::operator()) which get's called instead of
> TestKernel::operator().
>
> Note that Program will not be able to know about the concrete
> child classes of Kernel so it cannot dynamic_cast<ConcretKernel*>
> the pointers and I don't want to use maschine-specific ways
> like __decltype.

There are lots of ways to skin this cat.

The smallest change to your code I think would be this though.

---
thread t( boost::bind( &Kernel::operator(), m_kernel[i] ) );
t.join();
---
Regards,
   Nigel

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