Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualMatt-D

Posted 18 January 2013 - 08:23 PM

(cleaned)

#9Matt-D

Posted 18 January 2013 - 08:21 PM

(double)


#8Matt-D

Posted 18 January 2013 - 08:13 PM

- std::make_shared is a great suggestion, you're not supposed to be using "new" when you know you're going to use an std::shared_ptr
- you should seriously consider std::unique_ptr -- I've noticed it was already mentioned several times, but you haven't stated your reasons for not using it; in fact, std::unique_ptr should be your default choice -- consider std::shared_ptr to be a more specialized smart pointer which you should only use if you're actually sharing resources
- unfortunately, there's no std::make_unique (as of C++11), free free to grab it from here -- http://herbsutter.com/gotw/_102/ -- a pretty good read, BTW

Last but not least, please carefully read this before proceeding further: http://www.informit.com/articles/article.aspx?p=1944072
It's very worrying that "changing all my pointers to std::shared_ptrs" was even considered, given that std::unique_ptr should be the first / default / preferred choice. IMHO, attempting to throw random smart pointers at the problem, without first reading about the options and the associated trade-offs (using "new" when constructing std::shared_ptr is also a bad sign), is quite an anti-pattern and rather risky. Dynamic memory management is not trivial; high-performance dynamic memory management is even less so. Consider yourself warned ;-)

#7Matt-D

Posted 18 January 2013 - 08:10 PM

- std::make_shared is a great suggestion, you're not supposed to be using "new" when you know you're going to use an std::shared_ptr
- you should seriously consider std::unique_ptr -- I've noticed it was already mentioned several times, but you haven't stated your reasons for not using it; in fact, std::unique_ptr should be your default choice -- consider std::shared_ptr to be a more specialized smart pointer which you should only use if you're actually sharing resources
- unfortunately, there's no std::make_unique (as of C++11), free free to grab it from here -- http://herbsutter.com/gotw/_102/ -- a pretty good read, BTW

Last but not least, please carefully read this before proceeding further: http://www.informit.com/articles/article.aspx?p=1944072
It's very worrying that "changing all my pointers to std::shared_ptrs" was even considered, given that std::unique_ptr should be the first / default / preferred choice. IMHO, attempting to throw random smart pointers at the problem, without first reading about the options and the associated trade-offs (using "new" when constructing std::shared_ptr is also a bad sign), is quite an anti-pattern and rather risky. Consider yourself warned ;-)

#6Matt-D

Posted 18 January 2013 - 08:09 PM

- std::make_shared is a great suggestion, you're not supposed to be using "new" when you know you're going to use an std::shared_ptr
- you should seriously consider std::unique_ptr -- I've noticed it was already mentioned several times, but you haven't stated your reasons for not using it; in fact, std::unique_ptr should be your default choice -- consider shared_ptr to be a more specialized smart pointer which you should only use if you're actually sharing resources
- unfortunately, there's no std::make_unique (as of C++11), free free to grab it from here -- http://herbsutter.com/gotw/_102/ -- a pretty good read, BTW

Last but not least, please carefully read this before proceeding further: http://www.informit.com/articles/article.aspx?p=1944072
It's very worrying that "changing all my pointers to std::shared_ptrs" was even considered, given that std::unique_ptr should be the first / default / preferred choice. IMHO, attempting to throw random smart pointers at the problem, without first reading about the options and the associated trade-offs (using "new" when constructing std::shared_ptr is also a bad sign), is quite an anti-pattern and rather risky. Consider yourself warned ;-)

#5Matt-D

Posted 18 January 2013 - 08:08 PM

- std::make_shared is a great suggestion, you're not supposed to be using "new" when you know you're going to use an std::shared_ptr
- you should seriously consider std::unique_ptr -- I've noticed it was already mentioned several times, but you haven't stated your reasons for not using it; in fact, std::unique_ptr should be your default choice -- consider shared_ptr to be a more specialized smart pointer which you should only use if you're actually sharing resources
- unfortunately, there's no std::make_unique (as of C++11), free free to grab it from here -- http://herbsutter.com/gotw/_102/ -- a pretty good read, BTW

Last but not least, please read this: http://www.informit.com/articles/article.aspx?p=1944072
It's very worrying that "changing all my pointers to std::shared_ptrs" was even considered, given that std::unique_ptr should be the first / default / preferred choice. IMHO, attempting to throw random smart pointers at the problem, without first reading about the options and the associated trade-offs (using "new" when constructing std::shared_ptr is also a bad sign), is quite an anti-pattern and rather risky. Consider yourself warned ;-)

PARTNERS