C ++ 11: what's the difference between atomic <T> :: store and atomic_store <T>

One of them is a member function of the template class std::atomic, one of them is a function of the template, it seems that they are doing the same. Since it stdis a class library, why does it provide both a class and a non-classical version, I think the same operation?

Are there any real differences between them?

+4
source share
2 answers

There is no difference in semantics. Free functions were an attempt to achieve source compatibility with C11:

#ifdef __cplusplus
#include <atomic>
#define _Atomic(X) std::atomic<X>
#else
#include <stdatomic.h>
#endif

_Atomic(int) c;

int get_c(void) { 
    return atomic_load(&c); 
}
+7
source

, - , - . - atomic<T> , , ..

, atomic_store .

+1

Source: https://habr.com/ru/post/1682338/


All Articles