Jump to content
  • Advertisement
Sign in to follow this  
Wavesonics

intrusive_ptr for derived class?

This topic is 3682 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to only implement the intrusive pointer functions in a base class, then have all derived children use that? so:
void intrusive_ptr_add_ref( GameObject* p );
void intrusive_ptr_release( GameObject* p );

typedef boost::intrusive_ptr< class GameObject > GameObject_ptr;
typedef boost::intrusive_ptr< class DerivedObject > DerivedObject_ptr;

class GameObject;
class DerivedObject : public GameObject;


And a DerivedObject_ptr would call:
void intrusive_ptr_release( GameObject* p );


when it went out of scope? I would think a pointer to a derived class could be implicitly converted to a pointer of a base class here. So it would pick the intrusive_ptr_release function wich accepts the base*.

Share this post


Link to post
Share on other sites
Advertisement
This is the specific error I am getting:

Quote:

intrusive_ptr.hpp(83) : Error : (10248) function call '[boost::intrusive_ptr<boost::intrusive_ptr<GOBox>>].intrusive_ptr_release({lval} boost::intrusive_ptr<GOBox> *)' does not match
'intrusive_ptr_release(const ReferenceCounted *)'

(point of instantiation: 'FStateBattle::createBox(const Vector3D<float> &, const Rotation3D &, const Vector3D<float> &)')

(instantiating: 'boost::intrusive_ptr<boost::intrusive_ptr<GOBox>>::~intrusive_ptr()')

FStateBattle.cpp(81) : Note : (10544) (corresponding point of instantiation for 'boost::intrusive_ptr<boost::intrusive_ptr<GOBox>>::~intrusive_ptr()')




Where ReferenceCounted is a base class that they all derive from.

Share this post


Link to post
Share on other sites
Answer may lie in:

boost::intrusive_ptr<boost::intrusive_ptr<GOBox> >

That's pointer to pointer of GOBox.

Share this post


Link to post
Share on other sites
Yes i solved this, I was casting to an intrusive pointer rather than to the pointer type I wanted. Thank you for the reply though.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!