From dd09439feec14362b8d88c6fad662c9996426b67 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 20 Jul 2018 21:45:20 -0400 Subject: vfs: Use variable template variants of std::is_trivially_copyable Provides the same behavior, but with less writing --- src/core/file_sys/vfs.h | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/core/file_sys/vfs.h b/src/core/file_sys/vfs.h index edd689c68..d108ab1f4 100644 --- a/src/core/file_sys/vfs.h +++ b/src/core/file_sys/vfs.h @@ -59,8 +59,7 @@ struct VfsFile : NonCopyable { // Returns the number of bytes (sizeof(T)*number_elements) read successfully. template size_t ReadArray(T* data, size_t number_elements, size_t offset = 0) const { - static_assert(std::is_trivially_copyable::value, - "Data type must be trivially copyable."); + static_assert(std::is_trivially_copyable_v, "Data type must be trivially copyable."); return Read(reinterpret_cast(data), number_elements * sizeof(T), offset); } @@ -69,8 +68,7 @@ struct VfsFile : NonCopyable { // Returns the number of bytes read successfully. template size_t ReadBytes(T* data, size_t size, size_t offset = 0) const { - static_assert(std::is_trivially_copyable::value, - "Data type must be trivially copyable."); + static_assert(std::is_trivially_copyable_v, "Data type must be trivially copyable."); return Read(reinterpret_cast(data), size, offset); } @@ -78,8 +76,7 @@ struct VfsFile : NonCopyable { // Returns the number of bytes read successfully (sizeof(T)). template size_t ReadObject(T* data, size_t offset = 0) const { - static_assert(std::is_trivially_copyable::value, - "Data type must be trivially copyable."); + static_assert(std::is_trivially_copyable_v, "Data type must be trivially copyable."); return Read(reinterpret_cast(data), sizeof(T), offset); } @@ -94,9 +91,7 @@ struct VfsFile : NonCopyable { // Returns the number of bytes (sizeof(T)*number_elements) written successfully. template size_t WriteArray(const T* data, size_t number_elements, size_t offset = 0) { - static_assert(std::is_trivially_copyable::value, - "Data type must be trivially copyable."); - + static_assert(std::is_trivially_copyable_v, "Data type must be trivially copyable."); return Write(data, number_elements * sizeof(T), offset); } @@ -104,8 +99,7 @@ struct VfsFile : NonCopyable { // Returns the number of bytes written successfully. template size_t WriteBytes(const T* data, size_t size, size_t offset = 0) { - static_assert(std::is_trivially_copyable::value, - "Data type must be trivially copyable."); + static_assert(std::is_trivially_copyable_v, "Data type must be trivially copyable."); return Write(reinterpret_cast(data), size, offset); } @@ -113,8 +107,7 @@ struct VfsFile : NonCopyable { // Returns the number of bytes written successfully (sizeof(T)). template size_t WriteObject(const T& data, size_t offset = 0) { - static_assert(std::is_trivially_copyable::value, - "Data type must be trivially copyable."); + static_assert(std::is_trivially_copyable_v, "Data type must be trivially copyable."); return Write(&data, sizeof(T), offset); } -- cgit v1.2.3