How can I use std::shared_ptr for array of double? Additionally what are advantages/disadvantages of using shared_ptr.
How can I use std::shared_ptr for array of double? Additionally what are advantages/disadvantages of
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends on what you’re after. If you just want a resizable array of doubles, go with
Example:
If sharing the ownership of said array matters to you, use e.g.
Example:
Alternatively, Boost has
which serves a similar purpose. See here:
http://www.boost.org/libs/smart_ptr/shared_array.htm
As far as a few advantages/disadvantages of shared_ptr go:
Pros
Cons