aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils/mem_ops.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/utils/mem_ops.h')
-rw-r--r--src/lib/utils/mem_ops.h15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/lib/utils/mem_ops.h b/src/lib/utils/mem_ops.h
index deb4c01f2..8e77c9e34 100644
--- a/src/lib/utils/mem_ops.h
+++ b/src/lib/utils/mem_ops.h
@@ -117,13 +117,6 @@ template<typename T> inline void clear_mem(T* ptr, size_t n)
clear_bytes(ptr, sizeof(T)*n);
}
-// is_trivially_copyable is missing in g++ < 5.0
-#if (BOTAN_GCC_VERSION > 0 && BOTAN_GCC_VERSION < 500)
-#define BOTAN_IS_TRIVIALLY_COPYABLE(T) true
-#else
-#define BOTAN_IS_TRIVIALLY_COPYABLE(T) std::is_trivially_copyable<T>::value
-#endif
-
/**
* Copy memory
* @param out the destination array
@@ -144,13 +137,13 @@ template<typename T> inline void copy_mem(T* out, const T* in, size_t n)
template<typename T> inline void typecast_copy(uint8_t out[], T in[], size_t N)
{
- static_assert(BOTAN_IS_TRIVIALLY_COPYABLE(T), "");
+ static_assert(std::is_trivially_copyable<T>::value, "Safe to memcpy");
std::memcpy(out, in, sizeof(T)*N);
}
template<typename T> inline void typecast_copy(T out[], const uint8_t in[], size_t N)
{
- static_assert(std::is_trivial<T>::value, "");
+ static_assert(std::is_trivial<T>::value, "Safe to memcpy");
std::memcpy(out, in, sizeof(T)*N);
}
@@ -161,13 +154,13 @@ template<typename T> inline void typecast_copy(uint8_t out[], T in)
template<typename T> inline void typecast_copy(T& out, const uint8_t in[])
{
- static_assert(std::is_trivial<typename std::decay<T>::type>::value, "");
+ static_assert(std::is_trivial<typename std::decay<T>::type>::value, "Safe case");
typecast_copy(&out, in, 1);
}
template <class To, class From> inline To typecast_copy(const From *src) noexcept
{
- static_assert(BOTAN_IS_TRIVIALLY_COPYABLE(From) && std::is_trivial<To>::value, "");
+ static_assert(std::is_trivially_copyable<From>::value && std::is_trivial<To>::value, "Safe for memcpy");
To dst;
std::memcpy(&dst, src, sizeof(To));
return dst;