If you are lucky, then you havent designed the classes that need shared pointer but dont have a readymade one.
If you are lucky and your entire program will run in single thread ...
Then you have chance of having a really cheap shared pointer.
Use a base class SharedPtr. Derive all the object from that.
Objects of type SharedPtr will contain some free-store memory for counting.
When you are copying it, do increment
When you are destroying it decrement and free the object if necessary.
Et cetra et cetra of the shared pointer semantics.
Store pointers as SharedPtr. and do downcast whenever you need some operation.
I know this is cheapo solution, but...
1. Multithreaded will require locks. Costly + involved.
2. Template programming. Will probably require a half-day and another half day to debug and fix your issues, which you will get when you try to replicate shared_ptr from BOOST
If yo uhave just couple of classes whose existence is more important and not with hundreds of operations on them, then you can try this approach.
Btw, this is kind of "template-pattern"
shared_ptrheader-only?shared_ptrand be done with it. Though that obviously begs the question why the hell you can't use boost header files in the first place.