Stefan Schimanski <[EMAIL PROTECTED]> writes: | > | auto_ptr<Inset> MathMacro::doClone() const | > | { | > | - return auto_ptr<Inset>(new MathMacro(*this)); | > | + MathMacro * copy = new MathMacro(*this); | > | + copy->needsUpdate_ = true; | > | + copy->expanded_.cell(0).clear(); | > | + return auto_ptr<Inset>(copy); | > | } | > | > Why not: | > | > auto_ptr<Inset> tmpInset(new MathMacro(*this)); | > tmpInset->needsUpdate_ = true; | > tmpInset->expanded_.cell(0).clear(); | > return tmpInset; | > ? | > | > A bit safer if it works. | | Why is it safer?
If an exception is thrown you don't leak. Also it takes advantage of NRVO. -- Lgb