https://github.com/avakar/atomic_ref
Header-only implementation of std::atomic_ref for C++14
https://github.com/avakar/atomic_ref
atomic cpp cpp14 polyfill
Last synced: about 2 months ago
JSON representation
Header-only implementation of std::atomic_ref for C++14
- Host: GitHub
- URL: https://github.com/avakar/atomic_ref
- Owner: avakar
- License: mit
- Created: 2019-02-28T21:06:43.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-08-19T19:06:30.000Z (almost 3 years ago)
- Last Synced: 2025-03-22T15:02:20.150Z (2 months ago)
- Topics: atomic, cpp, cpp14, polyfill
- Language: C++
- Homepage:
- Size: 18.6 KB
- Stars: 9
- Watchers: 3
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# atomic_ref

Header-only implementation of [std::atomic_ref][1] for C++14.
Currently supports Microsoft Visual Studio on x86 and amd64,
and GCC/clang with support for __atomic builtins.[1]: https://en.cppreference.com/w/cpp/atomic/atomic_ref
## Getting started
Place the library anywhere and add the `include` directory to your
project's include paths.Bring `avakar::atomic_ref` to your namespace and enjoy.
#include
using avakar::atomic_ref;## License
The software is distributed under the terms of the MIT license.
## Lock- and wait-freeness
The standard mandates a constexpr bool member called `is_always_lock_free`.
This implementation also defines a bool constexpr member `is_always_wait_free`.
Note that in particular, operations on `uint64_t` in Intel's 32-bit platforms
are not wait free.## Safe variant
The library also defines the class `avakar::safe_atomic_ref`,
which forces you to use the more verbose function calls insted of operators.
In particual, `safe_atomic_ref` doesn't provide* implicit conversion operator (`operator T`),
* pre- and post-increment,
* pre- and post-decrement,
* the assignment operator, or
* any of the compound assignment operators.