diff options
| author | 2018-07-19 11:48:16 -0700 | |
|---|---|---|
| committer | 2018-07-19 11:48:16 -0700 | |
| commit | e91ba6c057286e683220310e2af26d8c63da0cf2 (patch) | |
| tree | e02f9081f681d961f46fdec4374dc4850ef680f3 /src | |
| parent | Merge pull request #710 from lioncash/unused (diff) | |
| parent | common/swap: Remove unnecessary const on return value of swap() (diff) | |
| download | yuzu-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.h | 100 |
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 | ||
| 168 | template <typename T, typename F> | 168 | template <typename T, typename F> |
| 169 | struct swap_struct_t { | 169 | struct swap_struct_t { |
| 170 | typedef swap_struct_t<T, F> swapped_t; | 170 | using swapped_t = swap_struct_t; |
| 171 | 171 | ||
| 172 | protected: | 172 | protected: |
| 173 | T value = T(); | 173 | T value = T(); |
| @@ -177,7 +177,7 @@ protected: | |||
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | public: | 179 | public: |
| 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 | ||
| 542 | template <typename S, typename T, typename F> | 542 | template <typename S, typename T, typename F> |
| 543 | S operator&(const swap_struct_t<T, F> v, const S& i) { | 543 | S 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 |
| 609 | typedef u32 u32_le; | 609 | using u16_le = u16; |
| 610 | typedef u16 u16_le; | 610 | using u32_le = u32; |
| 611 | typedef u64 u64_le; | 611 | using u64_le = u64; |
| 612 | 612 | ||
| 613 | typedef s32 s32_le; | 613 | using s16_le = s16; |
| 614 | typedef s16 s16_le; | 614 | using s32_le = s32; |
| 615 | typedef s64 s64_le; | 615 | using s64_le = s64; |
| 616 | 616 | ||
| 617 | typedef float float_le; | 617 | using float_le = float; |
| 618 | typedef double double_le; | 618 | using double_le = double; |
| 619 | 619 | ||
| 620 | typedef swap_struct_t<u64, swap_64_t<u64>> u64_be; | 620 | using u64_be = swap_struct_t<u64, swap_64_t<u64>>; |
| 621 | typedef swap_struct_t<s64, swap_64_t<s64>> s64_be; | 621 | using s64_be = swap_struct_t<s64, swap_64_t<s64>>; |
| 622 | 622 | ||
| 623 | typedef swap_struct_t<u32, swap_32_t<u32>> u32_be; | 623 | using u32_be = swap_struct_t<u32, swap_32_t<u32>>; |
| 624 | typedef swap_struct_t<s32, swap_32_t<s32>> s32_be; | 624 | using s32_be = swap_struct_t<s32, swap_32_t<s32>>; |
| 625 | 625 | ||
| 626 | typedef swap_struct_t<u16, swap_16_t<u16>> u16_be; | 626 | using u16_be = swap_struct_t<u16, swap_16_t<u16>>; |
| 627 | typedef swap_struct_t<s16, swap_16_t<s16>> s16_be; | 627 | using s16_be = swap_struct_t<s16, swap_16_t<s16>>; |
| 628 | 628 | ||
| 629 | typedef swap_struct_t<float, swap_float_t<float>> float_be; | 629 | using float_be = swap_struct_t<float, swap_float_t<float>>; |
| 630 | typedef swap_struct_t<double, swap_double_t<double>> double_be; | 630 | using double_be = swap_struct_t<double, swap_double_t<double>>; |
| 631 | #else | 631 | #else |
| 632 | 632 | ||
| 633 | typedef swap_struct_t<u64, swap_64_t<u64>> u64_le; | 633 | using u64_le = swap_struct_t<u64, swap_64_t<u64>>; |
| 634 | typedef swap_struct_t<s64, swap_64_t<s64>> s64_le; | 634 | using s64_le = swap_struct_t<s64, swap_64_t<s64>>; |
| 635 | 635 | ||
| 636 | typedef swap_struct_t<u32, swap_32_t<u32>> u32_le; | 636 | using u32_le = swap_struct_t<u32, swap_32_t<u32>>; |
| 637 | typedef swap_struct_t<s32, swap_32_t<s32>> s32_le; | 637 | using s32_le = swap_struct_t<s32, swap_32_t<s32>>; |
| 638 | 638 | ||
| 639 | typedef swap_struct_t<u16, swap_16_t<u16>> u16_le; | 639 | using u16_le = swap_struct_t<u16, swap_16_t<u16>>; |
| 640 | typedef swap_struct_t<s16, swap_16_t<s16>> s16_le; | 640 | using s16_le = swap_struct_t<s16, swap_16_t<s16>>; |
| 641 | 641 | ||
| 642 | typedef swap_struct_t<float, swap_float_t<float>> float_le; | 642 | using float_le = swap_struct_t<float, swap_float_t<float>>; |
| 643 | typedef swap_struct_t<double, swap_double_t<double>> double_le; | 643 | using double_le = swap_struct_t<double, swap_double_t<double>>; |
| 644 | 644 | ||
| 645 | typedef u32 u32_be; | 645 | using u16_be = u16; |
| 646 | typedef u16 u16_be; | 646 | using u32_be = u32; |
| 647 | typedef u64 u64_be; | 647 | using u64_be = u64; |
| 648 | 648 | ||
| 649 | typedef s32 s32_be; | 649 | using s16_be = s16; |
| 650 | typedef s16 s16_be; | 650 | using s32_be = s32; |
| 651 | typedef s64 s64_be; | 651 | using s64_be = s64; |
| 652 | 652 | ||
| 653 | typedef float float_be; | 653 | using float_be = float; |
| 654 | typedef double double_be; | 654 | using double_be = double; |
| 655 | 655 | ||
| 656 | #endif | 656 | #endif |