Skip to content

Instantly share code, notes, and snippets.

@CyberDNIWE
Created November 22, 2022 06:57
Show Gist options
  • Save CyberDNIWE/83a56cc15627580ba42d6aa51417b3cd to your computer and use it in GitHub Desktop.
Save CyberDNIWE/83a56cc15627580ba42d6aa51417b3cd to your computer and use it in GitHub Desktop.
poorly::aligned_storage
// Equivalent to std::aligned_storage (taken from https://gist.github.com/calebh/fd00632d9c616d4b0c14e7c2865f3085)
namespace poorly
{
template<unsigned int Length, unsigned int Alignment>
struct aligned_storage
{
struct type
{ alignas(Alignment) unsigned char data[Length]; };
};
};
// Usage:
// using data_t = poorly::aligned_storage<sizeof(int), alignof(int)>;
// data_t intWorthOfBytes = data_t();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment