Skip to content

Instantly share code, notes, and snippets.

@PIlin
Created February 3, 2015 17:04
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 PIlin/442a0f516e57458328d8 to your computer and use it in GitHub Desktop.
Save PIlin/442a0f516e57458328d8 to your computer and use it in GitHub Desktop.
template <int A> struct aligned;
template <> struct __declspec(align(1)) aligned < 1 > {};
template <> struct __declspec(align(2)) aligned < 2 > {};
template <> struct __declspec(align(4)) aligned < 4 > {};
template <> struct __declspec(align(8)) aligned < 8 > {};
template <> struct __declspec(align(16)) aligned < 16 > {};
template <> struct __declspec(align(32)) aligned < 32 > {};
template <int size, int align>
union aligned_type {
aligned<align> mAligned;
char mPad[size];
};
template <int size, int align>
struct aligned_storage {
using type = aligned_type < size, align > ;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment