Skip to content

Instantly share code, notes, and snippets.

@danlark1
Created January 11, 2020 23:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danlark1/03fc2b64c61b1d7de4345320a8253303 to your computer and use it in GitHub Desktop.
Save danlark1/03fc2b64c61b1d7de4345320a8253303 to your computer and use it in GitHub Desktop.
struct empty_struct {};
struct dummy_type {
static_assert(sizeof(T) % sizeof(empty_struct) == 0, "");
// Use an array to avoid GCC 6 placement-new warning.
empty_struct data[sizeof(T) / sizeof(empty_struct)];
};
// Data storage
union {
T data_;
dummy_type dummy_;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment