|
Boost Users : |
From: Jason Winnebeck (yg-boost-users_at_[hidden])
Date: 2003-07-19 21:31:51
No Russel I just tried that, it won't work. That's sort of how my code
was. Your TheBase class is my SharedThis class from eariler example,
and I had non-templated. It wouldn't compile because the
enable_shared_from_this couldn't cast some pointer.
Jason
Russell Hind wrote:
> Jason Winnebeck wrote:
>
>
>>I tried using enable_shared_from_this with virtual inheritance, just to
>>see if it would work. I couldn't get it to work. The first barrier is
>>that enable_shared_from_this is a templated class, and from what I
>>understand is that two template instantiations of a class are two
>>entirely different classes, so I didn't even try to use virtual on that.
>>
>
>
> Sorry, I completely missed that enable_shared_from_this was a template
> class. Yes in that case it won't work unless possibly you did something
> like this
>
> class TheBase : public enable_shared_from_this<TheBase>
> {
> };
>
> class Base1 : virtual public TheBase
> {
> };
>
> class Base2 : virtual public TheBase
> {
> };
>
> class MyClass : public Base1, public Base2
> {
> };
>
> But then you may need dynamic_casts somewhere to get the actual
> interface pointer you required later so don't know if that will be possible.
>
> Thanks
>
> Russell
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