boost::intrusive_ptr wrapper

Started by
13 comments, last by jpetrie 16 years, 3 months ago
i would like to create a class wrapper for boost::intrusive_ptr which just ads a few function id like... it shold work just like intrusive_ptr just with these extra functions... is this possible? im having problem getting it working with the constructors... something like template<class T> class new_ptr : public boost::intrusive_ptr<T> { public: void NewFunction(){} }
Advertisement
It's certainly possible.

Quote:Original post by Dragon_Strike
im having problem getting it working with the constructors...

Could you be a little more specific?
NextWar: The Quest for Earth available now for Windows Phone 7.
well i dont know how to be very specific...
i get alot of different compiler errors that has to do with the templates...
ill be more specific once i get home from my job...

try to compile a similar class and you'll see...

is there anyway to derive both public and private?
Quote:
Original post by Dragon_Strike
well i dont know how to be very specific...


Listing the code that doesn't work might be a good start. [smile]
I thought id post here since i had no idea how to derive intrusive_ptr properly...

i was hoping that someone just showed me how to implement the constructor... but on second thought that might be hard if i dont understand what i want to do...

ill make another try and post the code and errors this time...

ill be back later 2 day with that... thx
Don't derive from boost::intrusive_ptr. It lacks a virtual destructor, meaning it isn't intended to be derived from. Use non-member functions if you want extra functionality.
ok thx...
then instead of writing a wrapper ill just rewrite the entire intrusive_ptr source code...
Quote:then instead of writing a wrapper ill just rewrite the entire intrusive_ptr source code...


That's not what SiCrane suggested. He meant the if you want to implement extra functionality, you can do so with non-member functions. There's really no need to completely rewrite the class.
Quote:
ok thx...
then instead of writing a wrapper ill just rewrite the entire intrusive_ptr source code...

That would be silly, wouldn't it?

What function do you want to add, and why? Either there is a better way to accomplish what you want without re-engineering an entire (rather complex) pointer class, or what you want to do is a bad idea anyway and you should find another way to do it.
Quote:Original post by Dragon_Strike
ok thx...
then instead of writing a wrapper ill just rewrite the entire intrusive_ptr source code...
Hm, that doesn't sound like a particularly good idea - it'll consume time and effort probably better spent elsewhere, and may very well leave you with buggy code (remember that the Boost libraries are widely used and have been thoroughly reviewed and tested).

What extra functionality do you want to add?

This topic is closed to new replies.

Advertisement