Definition of "atomic object"

In my view atomicity - strictly speaking - does not apply to types or objects, it applies to operations, i.e. you can say an operation is atomic or not.

By an "atomic object" we understand an object whose public interface exposes only atomic operations, i.e. all operations you can do with that object are atomic.

In C and C++ it may be that the concepts are defined the other way around: first define atomic objects and then define atomic operations in terms of atomic objects. It probably made sense for C and C++ to define it this way because the wording of the standard is primarily concerned with defining the language. However from a theoretical and abstract functionality perspective atomic operations are the main concern.

The C++ has the standard std::atomic<T> class template which fits the above descriptions.


The C++ standard imposes a set of rules on operations and effects of operations on atomic objects ([intro.races]). If all operations on an object satisfy those rules, then that object is atomic.

the phrase "atomic object" means "object of atomic type," does it not?

It is not worded so in the standard. But since the effect of operations is determined by the type of the object, this is not an unreasonable conclusion. Also correspondingly: Atomic type is a type whose instances are atomic objects.

The C++ standard library provides a set of types which are guaranteed to be atomic, as well as functions for those types which are guaranteed to be atomic operations ([atomics]).

properly aligned object small enough that hardware could handle it atomically.

C++ standard specifies nothing about alignment or size of atomic objects.

If an object/type is guaranteed to be atomic (see [atomics]), and if the hardware has such requirements for atomicity, then either the implementation of the language must guarantee that those requirements are met, or the implementation must employ locks to enforce atomicity.