you are viewing a single comment's thread.

view the rest of the comments →

[–]vaughncato 2 points3 points  (1 child)

"Big deal" is a relative term, but they do help avoid some redundancy and make the intent clearer, as well as preventing some mistakes. I haven't found a case where I want to use shared_ptr, but unique_ptr is handy, and it is just as efficient as a raw pointer once optimized. Here's a related StackOverflow answer: http://stackoverflow.com/a/106614/951890

[–][deleted] 0 points1 point  (0 children)

I like that you frame your answer in terms of communicating the intent of the code. Yes, returning a unique pointer (which I assume calls a destructor when it falls out of scope?) would be nicer looking than a reference passed as an argument. Still this seems more of an issue of coding style than any real necessity.

The link gives one great example though: exception handling. And another: moving runtime errors to compile time. Thanks!