summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2018-08-07 13:31:57 -0400
committerGravatar Lioncash2018-08-07 19:34:47 -0400
commita7d6efc5201960b351fee4760663388dd946ab8e (patch)
treeaea37b49caa9b3b71a98a1266d7786ac39079e2f /src
parentMerge pull request #971 from DarkLordZach/mbedtls-2.12.0 (diff)
downloadyuzu-a7d6efc5201960b351fee4760663388dd946ab8e.tar.gz
yuzu-a7d6efc5201960b351fee4760663388dd946ab8e.tar.xz
yuzu-a7d6efc5201960b351fee4760663388dd946ab8e.zip
common: Convert type traits templates over to variable template versions where applicable
Uses the C++17 inline variable variants
Diffstat (limited to 'src')
-rw-r--r--src/common/alignment.h4
-rw-r--r--src/common/bit_set.h2
-rw-r--r--src/common/file_util.h10
-rw-r--r--src/common/hash.h4
-rw-r--r--src/common/x64/xbyak_util.h2
5 files changed, 11 insertions, 11 deletions
diff --git a/src/common/alignment.h b/src/common/alignment.h
index b77da4a92..b9dd38746 100644
--- a/src/common/alignment.h
+++ b/src/common/alignment.h
@@ -9,13 +9,13 @@ namespace Common {
9 9
10template <typename T> 10template <typename T>
11constexpr T AlignUp(T value, size_t size) { 11constexpr T AlignUp(T value, size_t size) {
12 static_assert(std::is_unsigned<T>::value, "T must be an unsigned value."); 12 static_assert(std::is_unsigned_v<T>, "T must be an unsigned value.");
13 return static_cast<T>(value + (size - value % size) % size); 13 return static_cast<T>(value + (size - value % size) % size);
14} 14}
15 15
16template <typename T> 16template <typename T>
17constexpr T AlignDown(T value, size_t size) { 17constexpr T AlignDown(T value, size_t size) {
18 static_assert(std::is_unsigned<T>::value, "T must be an unsigned value."); 18 static_assert(std::is_unsigned_v<T>, "T must be an unsigned value.");
19 return static_cast<T>(value - value % size); 19 return static_cast<T>(value - value % size);
20} 20}
21 21
diff --git a/src/common/bit_set.h b/src/common/bit_set.h
index 84e3cbe58..5a197d8c1 100644
--- a/src/common/bit_set.h
+++ b/src/common/bit_set.h
@@ -96,7 +96,7 @@ static inline int LeastSignificantSetBit(u64 val) {
96 96
97template <typename IntTy> 97template <typename IntTy>
98class BitSet { 98class BitSet {
99 static_assert(!std::is_signed<IntTy>::value, "BitSet should not be used with signed types"); 99 static_assert(!std::is_signed_v<IntTy>, "BitSet should not be used with signed types");
100 100
101public: 101public:
102 // A reference to a particular bit, returned from operator[]. 102 // A reference to a particular bit, returned from operator[].
diff --git a/src/common/file_util.h b/src/common/file_util.h
index 28697d527..7f2a5cb63 100644
--- a/src/common/file_util.h
+++ b/src/common/file_util.h
@@ -207,7 +207,7 @@ public:
207 207
208 template <typename T> 208 template <typename T>
209 size_t ReadArray(T* data, size_t length) const { 209 size_t ReadArray(T* data, size_t length) const {
210 static_assert(std::is_trivially_copyable<T>(), 210 static_assert(std::is_trivially_copyable_v<T>,
211 "Given array does not consist of trivially copyable objects"); 211 "Given array does not consist of trivially copyable objects");
212 212
213 if (!IsOpen()) 213 if (!IsOpen())
@@ -218,7 +218,7 @@ public:
218 218
219 template <typename T> 219 template <typename T>
220 size_t WriteArray(const T* data, size_t length) { 220 size_t WriteArray(const T* data, size_t length) {
221 static_assert(std::is_trivially_copyable<T>(), 221 static_assert(std::is_trivially_copyable_v<T>,
222 "Given array does not consist of trivially copyable objects"); 222 "Given array does not consist of trivially copyable objects");
223 if (!IsOpen()) 223 if (!IsOpen())
224 return -1; 224 return -1;
@@ -227,19 +227,19 @@ public:
227 227
228 template <typename T> 228 template <typename T>
229 size_t ReadBytes(T* data, size_t length) const { 229 size_t ReadBytes(T* data, size_t length) const {
230 static_assert(std::is_trivially_copyable<T>(), "T must be trivially copyable"); 230 static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable");
231 return ReadArray(reinterpret_cast<char*>(data), length); 231 return ReadArray(reinterpret_cast<char*>(data), length);
232 } 232 }
233 233
234 template <typename T> 234 template <typename T>
235 size_t WriteBytes(const T* data, size_t length) { 235 size_t WriteBytes(const T* data, size_t length) {
236 static_assert(std::is_trivially_copyable<T>(), "T must be trivially copyable"); 236 static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable");
237 return WriteArray(reinterpret_cast<const char*>(data), length); 237 return WriteArray(reinterpret_cast<const char*>(data), length);
238 } 238 }
239 239
240 template <typename T> 240 template <typename T>
241 size_t WriteObject(const T& object) { 241 size_t WriteObject(const T& object) {
242 static_assert(!std::is_pointer<T>::value, "Given object is a pointer"); 242 static_assert(!std::is_pointer_v<T>, "WriteObject arguments must not be a pointer");
243 return WriteArray(&object, 1); 243 return WriteArray(&object, 1);
244 } 244 }
245 245
diff --git a/src/common/hash.h b/src/common/hash.h
index 73c326980..2c761e545 100644
--- a/src/common/hash.h
+++ b/src/common/hash.h
@@ -28,7 +28,7 @@ static inline u64 ComputeHash64(const void* data, size_t len) {
28 */ 28 */
29template <typename T> 29template <typename T>
30static inline u64 ComputeStructHash64(const T& data) { 30static inline u64 ComputeStructHash64(const T& data) {
31 static_assert(std::is_trivially_copyable<T>(), 31 static_assert(std::is_trivially_copyable_v<T>,
32 "Type passed to ComputeStructHash64 must be trivially copyable"); 32 "Type passed to ComputeStructHash64 must be trivially copyable");
33 return ComputeHash64(&data, sizeof(data)); 33 return ComputeHash64(&data, sizeof(data));
34} 34}
@@ -38,7 +38,7 @@ template <typename T>
38struct HashableStruct { 38struct HashableStruct {
39 // In addition to being trivially copyable, T must also have a trivial default constructor, 39 // In addition to being trivially copyable, T must also have a trivial default constructor,
40 // because any member initialization would be overridden by memset 40 // because any member initialization would be overridden by memset
41 static_assert(std::is_trivial<T>(), "Type passed to HashableStruct must be trivial"); 41 static_assert(std::is_trivial_v<T>, "Type passed to HashableStruct must be trivial");
42 /* 42 /*
43 * We use a union because "implicitly-defined copy/move constructor for a union X copies the 43 * We use a union because "implicitly-defined copy/move constructor for a union X copies the
44 * object representation of X." and "implicitly-defined copy assignment operator for a union X 44 * object representation of X." and "implicitly-defined copy assignment operator for a union X
diff --git a/src/common/x64/xbyak_util.h b/src/common/x64/xbyak_util.h
index 0f52f704b..ec76e0a47 100644
--- a/src/common/x64/xbyak_util.h
+++ b/src/common/x64/xbyak_util.h
@@ -34,7 +34,7 @@ inline bool IsWithin2G(const Xbyak::CodeGenerator& code, uintptr_t target) {
34 34
35template <typename T> 35template <typename T>
36inline void CallFarFunction(Xbyak::CodeGenerator& code, const T f) { 36inline void CallFarFunction(Xbyak::CodeGenerator& code, const T f) {
37 static_assert(std::is_pointer<T>(), "Argument must be a (function) pointer."); 37 static_assert(std::is_pointer_v<T>, "Argument must be a (function) pointer.");
38 size_t addr = reinterpret_cast<size_t>(f); 38 size_t addr = reinterpret_cast<size_t>(f);
39 if (IsWithin2G(code, addr)) { 39 if (IsWithin2G(code, addr)) {
40 code.call(f); 40 code.call(f);