
25 Apr
2008
25 Apr
'08
9:41 a.m.
Hi Lex,
However, you also mentioned that the two options are different: (1) shared_ptr<Foo> bla(new Foo(fooInstance));
(2) shared_ptr<Foo> bla; bla = shared_ptr<Foo>(new Foo(fooInstance));
You mentioned that the second will create a temporary that will "go away". Can you elaborate on that. It seems to me that it shouldn't go away, as long as bla is within scope. I guess that was my main question originally, whether the second option is a correct way to set bla (when, say, it's a class member).
Have a look at http://www.boost.org/doc/libs/1_35_0/libs/smart_ptr/shared_ptr.htm#BestPract... Regards, Rainer