Meryl Silverburgh | 4 Jul 19:12

What should I do to switch my legacy application to use boost smart pointers

Hi,

I have a legacy application in C++, and I would like to switch it to
use boost smart pointers.
Can you please tell me what is the best approach for the switch?

This application uses stl vector as the class container,
vector<MyClass*>

function which takes in MyClass*
void f1(MyClass* aMyClass) { ...}

function which returns MyClass*
MyClass* f1() {

return new MyClass();
  }

I am thinking just global replace all MyClass* with MyClassPtr

And then  put  in a common .h file

typedef MyClassPtr shared_ptr<MyClass>

Will this approach work?

Thank you for any tips.
Boris | 18 Aug 16:53

Re: What should I do to switch my legacy application to use boost smart pointers

On Fri, 04 Jul 2008 19:16:35 +0200, Meryl Silverburgh  
<silverburgh.meryl <at> gmail.com> wrote:

> Hi,
>
> I have a legacy application in C++, and I would like to switch it to
> use boost smart pointers.
> Can you please tell me what is the best approach for the switch?
>
> This application uses stl vector as the class container,
> vector<MyClass*>

If the vector is the only owner of MyClass instances you could replace it  
with boost::ptr_vector<MyClass>.

Boris

> [...]

Gmane