diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/file_util.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/common/file_util.h b/src/common/file_util.h index 4c11849ee..32ff4d8ca 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h | |||
| @@ -202,11 +202,15 @@ public: | |||
| 202 | return items_written; | 202 | return items_written; |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | size_t ReadBytes(void* data, size_t length) { | 205 | template <typename T> |
| 206 | size_t ReadBytes(T* data, size_t length) { | ||
| 207 | static_assert(std::is_trivially_copyable<T>(), "T must be trivially copyable"); | ||
| 206 | return ReadArray(reinterpret_cast<char*>(data), length); | 208 | return ReadArray(reinterpret_cast<char*>(data), length); |
| 207 | } | 209 | } |
| 208 | 210 | ||
| 209 | size_t WriteBytes(const void* data, size_t length) { | 211 | template <typename T> |
| 212 | size_t WriteBytes(const T* data, size_t length) { | ||
| 213 | static_assert(std::is_trivially_copyable<T>(), "T must be trivially copyable"); | ||
| 210 | return WriteArray(reinterpret_cast<const char*>(data), length); | 214 | return WriteArray(reinterpret_cast<const char*>(data), length); |
| 211 | } | 215 | } |
| 212 | 216 | ||