From 34e29aae4fe9d296d57268809dfb78a34e705233 Mon Sep 17 00:00:00 2001 From: Chris Kennelly Date: Mon, 13 Mar 2023 10:10:12 -0700 Subject: Add ABSL_ATTRIBUTE_NO_UNIQUE_ADDRESS helper. PiperOrigin-RevId: 516245113 Change-Id: Idaef538c9392decbfdeb3ed3b3c109c795f92f4d --- absl/base/attributes.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'absl/base') diff --git a/absl/base/attributes.h b/absl/base/attributes.h index b7826e77..91bf954b 100644 --- a/absl/base/attributes.h +++ b/absl/base/attributes.h @@ -779,4 +779,18 @@ #define ABSL_ATTRIBUTE_TRIVIAL_ABI #endif +// ABSL_ATTRIBUTE_NO_UNIQUE_ADDRESS +// +// Indicates a data member can be optimized to occupy no space (if it is empty) +// and/or its tail padding can be used for other members. +// +// For code that is assured to only build with C++20 or later, prefer using +// the standard attribute `[[no_unique_address]]` directly instead of this +// macro. +#if ABSL_HAVE_CPP_ATTRIBUTE(no_unique_address) +#define ABSL_ATTRIBUTE_NO_UNIQUE_ADDRESS [[no_unique_address]] +#else +#define ABSL_ATTRIBUTE_NO_UNIQUE_ADDRESS +#endif + #endif // ABSL_BASE_ATTRIBUTES_H_ -- cgit v1.2.3