Why atomic overloads exist for shared_ptr

Why there are atomic overloads for shared_ptr, as described here , instead of being a specialization for std::atomicwhich deals with shared_ptrs. Seems incompatible with the object oriented patterns used by the rest of the C ++ library.

And to make sure that I understand this correctly, when using read copy idiom updateshared_ptr to implement we need to do all access (read and write) to shared pointers through these functions ??

+4
source share
1 answer

Because:

std:: atomic TriviallyCopyable T.

: http://en.cppreference.com/w/cpp/atomic/atomic

std::is_trivially_copyable<std::shared_ptr<int>>::value == false;

, std::atomic<> std::shared_ptr<>. , . ( std::atomic<> ); , , .

: .

+7

All Articles