I'm currently trying to fix some of the flaws in our code base by introducing the use of smart pointers. The code base is very large and interconnected, like a spider that had a lot of coffee.
I was wondering if people had tried before and what their approach was.
My first step was to typedef classes as shown below.
#ifndef USE_SMART_POINTERS #define USE_SMART_POINTERS 0 #endif #if USE_SMART_POINTERS == 1 #include <boost/smart_ptr.hpp> #endif namespace ProductX { // forward decleration class CTObject; //typedefs #if USE_SMART_POINTERS == 1 typedef boost::shared_ptr<CTObject> CTObjectPtr; #else typedef CTObject* CObjectPtr; #endif }
Now I understand that this will lead to a wealth of compilation areas such as
CTObjectPtr i = NULL;
Completely shut down if smart pointers are enabled.
I was wondering if there is anything that I could do at this early stage to reduce the mass of compilation errors, or, as I suspect, is just taking things on a case by case basis.
Cheers Rich
c ++ boost refactoring shared-ptr
Rich
source share