| 165 | |
| 166 | template <class T> |
| 167 | void Serializer::deserialize(T &obj) |
| 168 | { |
| 169 | // This should really be used to avoid simply copying complex objects that are not trivially copyable |
| 170 | // std::is_trivially_copyable is shipped with GCC 5 |
| 171 | // static_assert(std::is_trivially_copyable<T>::value, "Missing Serializer::deserialize overload for T = "/* __PRETTY_FUNCTION__*/); |
| 172 | |
| 173 | if (read + sizeof(T) > stream.cend()) { |
| 174 | throw Exception("Serializer::deserialize: Stream is missing bytes!"); |
| 175 | } |
| 176 | |
| 177 | auto objPtr = reinterpret_cast<uint8_t *>(&obj); |
| 178 | |
| 179 | // Copy the data into val |
| 180 | std::copy(read, read + sizeof(T), objPtr); |
| 181 | |
| 182 | read += sizeof(T); |
| 183 | } |
| 184 | |
| 185 | template <class T> |
| 186 | size_t Serializer::get_size(const T &obj) |