#include "Serializer.hpp" template const std::vector &Serializer::to_bytes(const T& object) { std::vector bytes; const byte *begin = reinterpret_cast(std::addressof(object)); const byte *end = begin + sizeof(T); std::copy(begin, end, std::begin(bytes)); return bytes; } template const T& Serializer::from_bytes(byte *bytes, T& object) { static_assert(std::is_trivially_copyable::value, "not a TriviallyCopyable type"); byte *begin_object = reinterpret_cast(std::addressof(object)); std::vector bytes_vector(&bytes); std::copy(bytes_vector.begin(), bytes_vector.end(), begin_object); return object; }