For sample code, etc, I would recommend to read D's atomic primitive implementations [2] instead of C++. C++ standard library is an unreadable monster. Fundamentally C++ atomic types are a flaw as std::atomic<int> is a type by itself, whereas in reality the operations has to be atomic. Also you can't get the value type for the type underneath the std::atomic template.
Whereas in D, the operations are atomic and you can operate them on the primitive types. You can see numerous examples in D's standard library implementation (which is readable than C++'s) [3][4]
[1] https://llvm.org/docs/Atomics.html
[2] https://github.com/dlang/druntime/blob/master/src/core/atomi...
[3] https://github.com/dlang/phobos/blob/master/std/concurrency....
[4] https://github.com/dlang/phobos/blob/master/std/parallelism....