$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Rainer Thaden (RThaden_at_[hidden])
Date: 2008-04-25 05:41:43
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#BestPractices
Regards,
Rainer