X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fmacros.hpp;h=b734652eea9ea89218d7e798edabed46fe272e73;hb=a8e336c2b57ff1e38f2a511aab8c2c6060c1796d;hp=49f163b42fb5a6c81cc3906f9016a06fac6383a2;hpb=21699d0f247ea2704113cea4c10b425d9a2f4a19;p=lttng-tools.git diff --git a/src/common/macros.hpp b/src/common/macros.hpp index 49f163b42..b734652ee 100644 --- a/src/common/macros.hpp +++ b/src/common/macros.hpp @@ -136,14 +136,45 @@ T *malloc(size_t size) */ template -struct is_pod_or_void +struct can_free { - static constexpr bool value = std::is_pod::value || std::is_void::value; + static constexpr bool value = std::is_trivially_destructible::value || std::is_void::value; }; -template::value>::type> +template::value>::type> void free(T *p) = delete; +template +struct can_memset +{ + static constexpr bool value = std::is_pod::value || std::is_void::value; +}; + +template ::value>::type> +void *memset(T *s, int c, size_t n) = delete; + +template +struct can_memcpy +{ + static constexpr bool value = std::is_trivially_copyable::value; +}; + +template ::value>::type, + typename = typename std::enable_if::value>::type> +void *memcpy(T *d, const U *s, size_t n) = delete; + +template +struct can_memmove +{ + static constexpr bool value = std::is_trivially_copyable::value; +}; + +template ::value>::type, + typename = typename std::enable_if::value>::type> +void *memmove(T *d, const U *s, size_t n) = delete; + #ifndef ARRAY_SIZE #define ARRAY_SIZE(array) (sizeof(array) / (sizeof((array)[0]))) #endif