Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It sounds like std::atomic_ref<T>::{load,store}(relaxed) to me. 1. ad-hoc atomicity with ref 2. no ordering

https://godbolt.org/z/4h893P7hG





I believe that lets the compiler reorder the accesses. So this would be fine for my second example but it would be broken for my first example.

({READ,WRITE}_ONCE() only lets the compiler reorder the accesses if they happen in the same C statement).

I think C++ doesn't have an equivalent because it just doesn't make sense as a primitive in very many environments.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: