Background
Since C++11, atomic operations on std::shared_ptr
can be done via std::atomic_...
methods found here, because the partial specialization as shown below is not possible:
std::atomic<std::shared_ptr<T>>
This is due to the fact that std::atomic
only accepts TriviallyCopyable types, and std::shared_ptr
(or std::weak_ptr
) is not trivially copyable.
However, as of C++20, these methods have been deprecated, and got replaced by the partial template specialization of std::atomic
for std::shared_ptr
as described here.
Question
I am not sure of
- Why
std::atomic_...
got replaced. - Techniques used to enable the partial template specialization of
std::atomic
for smart pointers.
Aucun commentaire:
Enregistrer un commentaire