mercredi 21 août 2019

Is volatile necessary for std::atomic?

this good answer says:

volatile is completely unnecessary when used with std::atomic.

However, std::atomic_fecth_sub provides an overloaded function:

template<class T>
T atomic_fetch_sub(volatile std::atomic<T>* obj,
    typename std::atomic<T>::difference_type arg ) noexcept;

My question is:

If volatile is completely unnecessary for std::atomic, why does the C++ standard provide an overloaded function for it?

Aucun commentaire:

Enregistrer un commentaire