AC_NO_UNIQUE_ADDRESS

C++20 introduced [[no_unique_address]] attribute, which makes empty class fields not waste any memory. In generic code it’s a good practice to apply it to all the class fields, unless a field is known to be non-empty. Previously, the only way to achieve a similar result was to use empty base optimization and compressed pairs based on it, which is very inconvenient and doesn’t work for final classes.

Unfortunately, the standard attribute is ignored in the current MSVC version. For portability we need a custom wrapper until that’s fixed. See MSVC blog, github issue.

Reference

Defines

AC_NO_UNIQUE_ADDRESS

Portable replacement for [[no_unique_address]] attribute.

Source code

Tests