Quote Originally Posted by gioni_go View Post
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.