summaryrefslogtreecommitdiff
path: root/cachepad.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'cachepad.hpp')
-rw-r--r--cachepad.hpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/cachepad.hpp b/cachepad.hpp
new file mode 100644
index 0000000..beb7528
--- /dev/null
+++ b/cachepad.hpp
@@ -0,0 +1,15 @@
+#pragma once
+
+template<typename T>
+struct cache_pad {
+ template<typename ...Arg>
+ cache_pad(Arg... args) : val(args...) {}
+
+ operator T () { return val; }
+ T& operator () () { return val; }
+
+ union {
+ T val;
+ char pad[(sizeof(T) + 63) / 64 * 64];
+ };
+} __attribute__ ((aligned (64))); // TODO: port to C++11 alignas once GCC support is old enough
contact: Jan Huwald // Impressum