Commit 4ed21909 authored by Phil Willoughby's avatar Phil Willoughby Committed by Facebook Github Bot

add FOLLY_ATTR_NO_UNIQUE_ADDRESS

Summary:
Add `FOLLY_NO_UNIQUE_ADDRESS ` to expose C++20's `[[no_unique_address]]` where available.

(Note: this ignores all push blocking failures!)

Reviewed By: pixelb

Differential Revision: D19375089

fbshipit-source-id: 9a83ae791002e02df5b93b61f20209e5f467a959
parent e1af1b05
......@@ -119,3 +119,28 @@
#else
#define FOLLY_COLD
#endif
/**
* no_unique_address indicates that a member variable can be optimized to
* occupy no space, rather than the minimum 1-byte used by default.
*
* class Empty {};
*
* class NonEmpty1 {
* FOLLY_NO_UNIQUE_ADDRESS Empty e;
* int f;
* };
*
* class NonEmpty2 {
* Empty e;
* int f;
* };
*
* sizeof(NonEmpty1); // may be == sizeof(int)
* sizeof(NonEmpty2); // must be > sizeof(int)
*/
#if FOLLY_HAS_CPP_ATTRIBUTE(no_unique_address)
#define FOLLY_ATTR_NO_UNIQUE_ADDRESS [[no_unique_address]]
#else
#define FOLLY_ATTR_NO_UNIQUE_ADDRESS
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment