chrono icon indicating copy to clipboard operation
chrono copied to clipboard

Improve exception safety with smart pointers

Open elfring opened this issue 7 years ago • 2 comments

Would you like to wrap any pointer data members with the class template “std::unique_ptr”?

elfring avatar Aug 15 '18 14:08 elfring

I assume you are talking about private data members in which case I am not so sure it is worth using unique_ptr. For data members that are made public (e.g., through accessors), it's almost always the case that a shared_ptr is needed (unless you found a case where that's not true?). Having said that, there are still places in Chrono where raw pointers are exposed to the user -- we fix these as we go along whenever we find the time.

rserban avatar Aug 18 '18 11:08 rserban

I suggest to achieve safe resource management.

elfring avatar Aug 18 '18 12:08 elfring