You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
std::shared_ptr can now be used for all instances where SharedData, SharedDataPointer, and ExplicitlySharedDataPointer were used.
Doing this will add robustness to the code base and make maintenance easier.
The text was updated successfully, but these errors were encountered:
I am not sure I understand this. The mentioned classes implemented the COW pattern (copy on write). SharedDataPointer does so implicitly (when calling non-const methods on an object with ref count > 1) and ExplicitlySharedDataPointer only detaches a shared instance on explicit request. How can std::shared_ptr be used instead while keeping this functionality?
jeffdiclemente
changed the title
Remove usSharedData.h and replace with usage of std::shared_ptr
Consider using std::shared_ptr instead of raw pointers in usSharedData.h
Mar 8, 2016
It helps if I read the code a little more closely...
You're right, the SharedDataPointer and ExplicitlySharedDataPointer can't be completely replaced with std::shared_ptr since they are used for copy-on-write.
After looking again, I can only say that perhaps we should consider using std::shared_ptr instead of a raw pointer within SharedDataPointer and ExplicitlySharedDataPointer to store the shared data object.
Additionally, I think there is a bug in usSharedData.h on line 75: inline const T* Data() const { return d; }.
Shouldn't this be inline T* Data() const { return d; }?
std::shared_ptr can now be used for all instances where
SharedData
,SharedDataPointer
, andExplicitlySharedDataPointer
were used.Doing this will add robustness to the code base and make maintenance easier.
The text was updated successfully, but these errors were encountered: