Re: shared_ptr inheritance query

Peter Dimov wrote:
Can you separate the interface and implementation parts of the policy into two classes, then inherit publicly from policy_interface and privately from policy_implementation?
Unfortunately not, the policy has to be able to generate shared pointers from itself - hence it needs access to shared_from_this. If I used a multiple inheritance solution, I would be forced to dynamic_cast across to the enable_shared_from_this class, which I don't want to do. Dave Handley

Dave Handley wrote:
Peter Dimov wrote:
Can you separate the interface and implementation parts of the policy into two classes, then inherit publicly from policy_interface and privately from policy_implementation?
Unfortunately not, the policy has to be able to generate shared pointers from itself - hence it needs access to shared_from_this. If I used a multiple inheritance solution, I would be forced to dynamic_cast across to the enable_shared_from_this class, which I don't want to do.
In this case, I see no other solution except making the inheritance from the policy public and making all of its members protected.
participants (2)
-
Dave Handley
-
Peter Dimov