summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2018-07-19 11:48:16 -0700
committerGravatar GitHub2018-07-19 11:48:16 -0700
commite91ba6c057286e683220310e2af26d8c63da0cf2 (patch)
treee02f9081f681d961f46fdec4374dc4850ef680f3 /src
parentMerge pull request #710 from lioncash/unused (diff)
parentcommon/swap: Remove unnecessary const on return value of swap() (diff)
downloadyuzu-e91ba6c057286e683220310e2af26d8c63da0cf2.tar.gz
yuzu-e91ba6c057286e683220310e2af26d8c63da0cf2.tar.xz
yuzu-e91ba6c057286e683220310e2af26d8c63da0cf2.zip
Merge pull request #711 from lioncash/swap
common/swap: Minor changes
Diffstat (limited to 'src')
-rw-r--r--src/common/swap.h100
1 files changed, 50 insertions, 50 deletions
diff --git a/src/common/swap.h b/src/common/swap.h
index f025f7450..fc7af4280 100644
--- a/src/common/swap.h
+++ b/src/common/swap.h
@@ -167,7 +167,7 @@ inline double swapd(double f) {
167 167
168template <typename T, typename F> 168template <typename T, typename F>
169struct swap_struct_t { 169struct swap_struct_t {
170 typedef swap_struct_t<T, F> swapped_t; 170 using swapped_t = swap_struct_t;
171 171
172protected: 172protected:
173 T value = T(); 173 T value = T();
@@ -177,7 +177,7 @@ protected:
177 } 177 }
178 178
179public: 179public:
180 T const swap() const { 180 T swap() const {
181 return swap(value); 181 return swap(value);
182 } 182 }
183 swap_struct_t() = default; 183 swap_struct_t() = default;
@@ -185,39 +185,39 @@ public:
185 185
186 template <typename S> 186 template <typename S>
187 swapped_t& operator=(const S& source) { 187 swapped_t& operator=(const S& source) {
188 value = swap((T)source); 188 value = swap(static_cast<T>(source));
189 return *this; 189 return *this;
190 } 190 }
191 191
192 operator s8() const { 192 operator s8() const {
193 return (s8)swap(); 193 return static_cast<s8>(swap());
194 } 194 }
195 operator u8() const { 195 operator u8() const {
196 return (u8)swap(); 196 return static_cast<u8>(swap());
197 } 197 }
198 operator s16() const { 198 operator s16() const {
199 return (s16)swap(); 199 return static_cast<s16>(swap());
200 } 200 }
201 operator u16() const { 201 operator u16() const {
202 return (u16)swap(); 202 return static_cast<u16>(swap());
203 } 203 }
204 operator s32() const { 204 operator s32() const {
205 return (s32)swap(); 205 return static_cast<s32>(swap());
206 } 206 }
207 operator u32() const { 207 operator u32() const {
208 return (u32)swap(); 208 return static_cast<u32>(swap());
209 } 209 }
210 operator s64() const { 210 operator s64() const {
211 return (s64)swap(); 211 return static_cast<s64>(swap());
212 } 212 }
213 operator u64() const { 213 operator u64() const {
214 return (u64)swap(); 214 return static_cast<u64>(swap());
215 } 215 }
216 operator float() const { 216 operator float() const {
217 return (float)swap(); 217 return static_cast<float>(swap());
218 } 218 }
219 operator double() const { 219 operator double() const {
220 return (double)swap(); 220 return static_cast<double>(swap());
221 } 221 }
222 222
223 // +v 223 // +v
@@ -253,7 +253,7 @@ public:
253 } 253 }
254 template <typename S> 254 template <typename S>
255 swapped_t operator+(const S& i) const { 255 swapped_t operator+(const S& i) const {
256 return swap() + (T)i; 256 return swap() + static_cast<T>(i);
257 } 257 }
258 // v - 5 258 // v - 5
259 swapped_t operator-(const swapped_t& i) const { 259 swapped_t operator-(const swapped_t& i) const {
@@ -261,7 +261,7 @@ public:
261 } 261 }
262 template <typename S> 262 template <typename S>
263 swapped_t operator-(const S& i) const { 263 swapped_t operator-(const S& i) const {
264 return swap() - (T)i; 264 return swap() - static_cast<T>(i);
265 } 265 }
266 266
267 // v += 5 267 // v += 5
@@ -271,7 +271,7 @@ public:
271 } 271 }
272 template <typename S> 272 template <typename S>
273 swapped_t& operator+=(const S& i) { 273 swapped_t& operator+=(const S& i) {
274 value = swap(swap() + (T)i); 274 value = swap(swap() + static_cast<T>(i));
275 return *this; 275 return *this;
276 } 276 }
277 // v -= 5 277 // v -= 5
@@ -281,7 +281,7 @@ public:
281 } 281 }
282 template <typename S> 282 template <typename S>
283 swapped_t& operator-=(const S& i) { 283 swapped_t& operator-=(const S& i) {
284 value = swap(swap() - (T)i); 284 value = swap(swap() - static_cast<T>(i));
285 return *this; 285 return *this;
286 } 286 }
287 287
@@ -541,7 +541,7 @@ S operator&(const S& i, const swap_struct_t<T, F> v) {
541 541
542template <typename S, typename T, typename F> 542template <typename S, typename T, typename F>
543S operator&(const swap_struct_t<T, F> v, const S& i) { 543S operator&(const swap_struct_t<T, F> v, const S& i) {
544 return (S)(v.swap() & i); 544 return static_cast<S>(v.swap() & i);
545} 545}
546 546
547// Comparaison 547// Comparaison
@@ -606,51 +606,51 @@ struct swap_double_t {
606}; 606};
607 607
608#if COMMON_LITTLE_ENDIAN 608#if COMMON_LITTLE_ENDIAN
609typedef u32 u32_le; 609using u16_le = u16;
610typedef u16 u16_le; 610using u32_le = u32;
611typedef u64 u64_le; 611using u64_le = u64;
612 612
613typedef s32 s32_le; 613using s16_le = s16;
614typedef s16 s16_le; 614using s32_le = s32;
615typedef s64 s64_le; 615using s64_le = s64;
616 616
617typedef float float_le; 617using float_le = float;
618typedef double double_le; 618using double_le = double;
619 619
620typedef swap_struct_t<u64, swap_64_t<u64>> u64_be; 620using u64_be = swap_struct_t<u64, swap_64_t<u64>>;
621typedef swap_struct_t<s64, swap_64_t<s64>> s64_be; 621using s64_be = swap_struct_t<s64, swap_64_t<s64>>;
622 622
623typedef swap_struct_t<u32, swap_32_t<u32>> u32_be; 623using u32_be = swap_struct_t<u32, swap_32_t<u32>>;
624typedef swap_struct_t<s32, swap_32_t<s32>> s32_be; 624using s32_be = swap_struct_t<s32, swap_32_t<s32>>;
625 625
626typedef swap_struct_t<u16, swap_16_t<u16>> u16_be; 626using u16_be = swap_struct_t<u16, swap_16_t<u16>>;
627typedef swap_struct_t<s16, swap_16_t<s16>> s16_be; 627using s16_be = swap_struct_t<s16, swap_16_t<s16>>;
628 628
629typedef swap_struct_t<float, swap_float_t<float>> float_be; 629using float_be = swap_struct_t<float, swap_float_t<float>>;
630typedef swap_struct_t<double, swap_double_t<double>> double_be; 630using double_be = swap_struct_t<double, swap_double_t<double>>;
631#else 631#else
632 632
633typedef swap_struct_t<u64, swap_64_t<u64>> u64_le; 633using u64_le = swap_struct_t<u64, swap_64_t<u64>>;
634typedef swap_struct_t<s64, swap_64_t<s64>> s64_le; 634using s64_le = swap_struct_t<s64, swap_64_t<s64>>;
635 635
636typedef swap_struct_t<u32, swap_32_t<u32>> u32_le; 636using u32_le = swap_struct_t<u32, swap_32_t<u32>>;
637typedef swap_struct_t<s32, swap_32_t<s32>> s32_le; 637using s32_le = swap_struct_t<s32, swap_32_t<s32>>;
638 638
639typedef swap_struct_t<u16, swap_16_t<u16>> u16_le; 639using u16_le = swap_struct_t<u16, swap_16_t<u16>>;
640typedef swap_struct_t<s16, swap_16_t<s16>> s16_le; 640using s16_le = swap_struct_t<s16, swap_16_t<s16>>;
641 641
642typedef swap_struct_t<float, swap_float_t<float>> float_le; 642using float_le = swap_struct_t<float, swap_float_t<float>>;
643typedef swap_struct_t<double, swap_double_t<double>> double_le; 643using double_le = swap_struct_t<double, swap_double_t<double>>;
644 644
645typedef u32 u32_be; 645using u16_be = u16;
646typedef u16 u16_be; 646using u32_be = u32;
647typedef u64 u64_be; 647using u64_be = u64;
648 648
649typedef s32 s32_be; 649using s16_be = s16;
650typedef s16 s16_be; 650using s32_be = s32;
651typedef s64 s64_be; 651using s64_be = s64;
652 652
653typedef float float_be; 653using float_be = float;
654typedef double double_be; 654using double_be = double;
655 655
656#endif 656#endif