summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2018-07-20 21:45:20 -0400
committerGravatar Lioncash2018-07-20 21:47:19 -0400
commitdd09439feec14362b8d88c6fad662c9996426b67 (patch)
tree9756cdbd337e790cf2a5f7ec94abc811b530992d /src
parentvfs: Amend constness on pointers in WriteBytes() and WriteArrays() member fun... (diff)
downloadyuzu-dd09439feec14362b8d88c6fad662c9996426b67.tar.gz
yuzu-dd09439feec14362b8d88c6fad662c9996426b67.tar.xz
yuzu-dd09439feec14362b8d88c6fad662c9996426b67.zip
vfs: Use variable template variants of std::is_trivially_copyable
Provides the same behavior, but with less writing
Diffstat (limited to 'src')
-rw-r--r--src/core/file_sys/vfs.h19
1 files changed, 6 insertions, 13 deletions
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 {
59 // Returns the number of bytes (sizeof(T)*number_elements) read successfully. 59 // Returns the number of bytes (sizeof(T)*number_elements) read successfully.
60 template <typename T> 60 template <typename T>
61 size_t ReadArray(T* data, size_t number_elements, size_t offset = 0) const { 61 size_t ReadArray(T* data, size_t number_elements, size_t offset = 0) const {
62 static_assert(std::is_trivially_copyable<T>::value, 62 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
63 "Data type must be trivially copyable.");
64 63
65 return Read(reinterpret_cast<u8*>(data), number_elements * sizeof(T), offset); 64 return Read(reinterpret_cast<u8*>(data), number_elements * sizeof(T), offset);
66 } 65 }
@@ -69,8 +68,7 @@ struct VfsFile : NonCopyable {
69 // Returns the number of bytes read successfully. 68 // Returns the number of bytes read successfully.
70 template <typename T> 69 template <typename T>
71 size_t ReadBytes(T* data, size_t size, size_t offset = 0) const { 70 size_t ReadBytes(T* data, size_t size, size_t offset = 0) const {
72 static_assert(std::is_trivially_copyable<T>::value, 71 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
73 "Data type must be trivially copyable.");
74 return Read(reinterpret_cast<u8*>(data), size, offset); 72 return Read(reinterpret_cast<u8*>(data), size, offset);
75 } 73 }
76 74
@@ -78,8 +76,7 @@ struct VfsFile : NonCopyable {
78 // Returns the number of bytes read successfully (sizeof(T)). 76 // Returns the number of bytes read successfully (sizeof(T)).
79 template <typename T> 77 template <typename T>
80 size_t ReadObject(T* data, size_t offset = 0) const { 78 size_t ReadObject(T* data, size_t offset = 0) const {
81 static_assert(std::is_trivially_copyable<T>::value, 79 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
82 "Data type must be trivially copyable.");
83 return Read(reinterpret_cast<u8*>(data), sizeof(T), offset); 80 return Read(reinterpret_cast<u8*>(data), sizeof(T), offset);
84 } 81 }
85 82
@@ -94,9 +91,7 @@ struct VfsFile : NonCopyable {
94 // Returns the number of bytes (sizeof(T)*number_elements) written successfully. 91 // Returns the number of bytes (sizeof(T)*number_elements) written successfully.
95 template <typename T> 92 template <typename T>
96 size_t WriteArray(const T* data, size_t number_elements, size_t offset = 0) { 93 size_t WriteArray(const T* data, size_t number_elements, size_t offset = 0) {
97 static_assert(std::is_trivially_copyable<T>::value, 94 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
98 "Data type must be trivially copyable.");
99
100 return Write(data, number_elements * sizeof(T), offset); 95 return Write(data, number_elements * sizeof(T), offset);
101 } 96 }
102 97
@@ -104,8 +99,7 @@ struct VfsFile : NonCopyable {
104 // Returns the number of bytes written successfully. 99 // Returns the number of bytes written successfully.
105 template <typename T> 100 template <typename T>
106 size_t WriteBytes(const T* data, size_t size, size_t offset = 0) { 101 size_t WriteBytes(const T* data, size_t size, size_t offset = 0) {
107 static_assert(std::is_trivially_copyable<T>::value, 102 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
108 "Data type must be trivially copyable.");
109 return Write(reinterpret_cast<const u8*>(data), size, offset); 103 return Write(reinterpret_cast<const u8*>(data), size, offset);
110 } 104 }
111 105
@@ -113,8 +107,7 @@ struct VfsFile : NonCopyable {
113 // Returns the number of bytes written successfully (sizeof(T)). 107 // Returns the number of bytes written successfully (sizeof(T)).
114 template <typename T> 108 template <typename T>
115 size_t WriteObject(const T& data, size_t offset = 0) { 109 size_t WriteObject(const T& data, size_t offset = 0) {
116 static_assert(std::is_trivially_copyable<T>::value, 110 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
117 "Data type must be trivially copyable.");
118 return Write(&data, sizeof(T), offset); 111 return Write(&data, sizeof(T), offset);
119 } 112 }
120 113