|
-
January 19th, 2010, 10:50 AM
#9
Re: C++ Smart Pointer Question
 Originally Posted by gioni_go
I am not sure if there is an alternative, but i wanted a smart pointer that uses internally only the stack , no heap allocations.
Your best option is to use intrusive_ptr from boost. You put the reference counter in the object. It means it will be located where the object is located, on the stack or on the heap. You don't have to make the counter threadsafe if you don't want to. It's up to you to increment/decrement the counter. Just make sure you don't delete the object if it wasn't allocated with new.
Piece of cake really and you get a robust and well tested smart pointer implementation for free.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|