From 86395f53634b3ef1ce76a7f1e5edfdb61f8ffd80 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sat, 25 Oct 2014 15:24:26 -0700 Subject: Fix header ranking --- src/compat/rawmem.hpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/compat/rawmem.hpp') diff --git a/src/compat/rawmem.hpp b/src/compat/rawmem.hpp index c271a56..66af204 100644 --- a/src/compat/rawmem.hpp +++ b/src/compat/rawmem.hpp @@ -22,6 +22,8 @@ #include #include +#include + #include "fwd.hpp" @@ -49,4 +51,23 @@ void really_memset0(uint8_t *dest, size_t n) { memset(dest, '\0', n); } + +template +struct is_trivially_copyable +: std::integral_constant +{}; + +template +void really_memzero_this(T *v) +{ + static_assert(is_trivially_copyable::value, "only for mostly-pod types"); + static_assert(std::is_class::value || std::is_union::value, "Only for user-defined structures (for now)"); + memset(v, '\0', sizeof(*v)); +} +template +void really_memzero_this(T (&)[n]) = delete; } // namespace tmwa -- cgit v1.2.3-60-g2f50