Which of the following three ways to create a new object and manage it with QSharedPointer is preferable?

class Foo;

QSharedPointer<Foo> f1, f2, f3; // class members


f1.reset(new Foo);

f2 = QSharedPointer<Foo>::create(); // or even f2 = f2.create()

f3.swap(QSharedPointer<Foo>::create()); // or f3.swap(f3.create()))


I find #2 the easiest to read. Do #2 and #3 perform any differently? Anything else to consider?



Hamish

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to