boost shared_ptr: diferença entre operator = e reset?
Existem diferenças entre os dois pedaços de código abaixo? Algum deles é preferível ao outro?
operator =
boost::shared_ptr<Blah> foo; // foo.ptr should be NULL
foo = boost::shared_ptr<Blah>(new Blah()); // Involves creation and copy of a shared_ptr?
restabelece
boost::shared_ptr<Blah> foo; // foo.ptr should be NULL
foo.reset(new Blah()); // foo.ptr should point now to a new Blah object
ota: Eu preciso definir o shared_ptr e defini-lo em uma linha diferente, porque eu estou usando em um pedaço de código como:
boost::shared_ptr<Blah> foo;
try
{
foo.reset...
}
foo...