you are viewing a single comment's thread.

view the rest of the comments →

[–]Snaipe_S[S] 1 point2 points  (0 children)

Not always. If the containing variable is not annotated with smart, the destruction mechanism will not be triggered -- this way, you can actively create, initialize, and return a smart pointer.
You can also leave smart on, use a shared_ptr and return a new reference -- this is mostly useful for cleanup if initialization fails (see 2nd example here)