C++ Logo

std-discussion

Advanced search

atomic_ref::required_alignment usefulness

From: Andrey Semashev <andrey.semashev_at_[hidden]>
Date: Sun, 9 Feb 2020 17:15:44 +0300
Hi,

As specified in N4849, atomic_ref<T>::required_alignment is:

   The alignment required for an object to be referenced by an atomic
   reference, which is at least alignof(T).

This wording does not give provision as to whether this alignment is
strict enough so that atomic_ref<T> is lock-free (provided that it can
be lock-free at all). At the same time, atomic_ref<T> does not provide a
constant for the alignment that guarantees lock-free operations (again,
provided that they can be lock-free). Let's call this missing constant
recommended_alignment.

Is my understanding correct? If so, it seems like required_alignment is
rather useless, as there seems to be no reason to make it anything other
than alignof(T). Why is recommended_alignment, which is much more
useful, missing?

Thanks.

Received on 2020-02-09 08:18:26