From 9e9a3262ebc90cacd2b19b41cf989abc9e21a962 Mon Sep 17 00:00:00 2001 From: oltolm Date: Wed, 20 Mar 2024 17:16:49 +0100 Subject: [PATCH] simplify template code like std::is_same::value --- Utilities/StrFmt.cpp | 2 +- Utilities/StrFmt.h | 6 +-- Utilities/bit_set.h | 4 +- rpcs3/Emu/CPU/CPUTranslator.h | 4 +- rpcs3/Emu/Cell/Modules/cellGem.cpp | 12 ++--- rpcs3/Emu/Cell/Modules/sceNp.cpp | 4 +- rpcs3/Emu/Cell/PPUCallback.h | 24 +++++----- rpcs3/Emu/Cell/PPUFunction.h | 28 ++++++------ rpcs3/Emu/Cell/PPUModule.h | 2 +- rpcs3/Emu/Cell/PPUThread.h | 4 +- rpcs3/Emu/IdManager.h | 2 +- rpcs3/Emu/Memory/vm_ptr.h | 4 +- rpcs3/Emu/Memory/vm_ref.h | 8 ++-- rpcs3/Emu/RSX/Common/BufferUtils.cpp | 2 +- rpcs3/Emu/RSX/Common/TextureUtils.cpp | 2 +- rpcs3/Emu/RSX/Common/texture_cache.h | 5 ++- rpcs3/Emu/RSX/Core/RSXContext.h | 1 + .../HomeMenu/overlay_home_menu_components.h | 2 +- .../RSX/Program/FragmentProgramDecompiler.cpp | 6 +-- rpcs3/Loader/ELF.h | 8 ++-- rpcs3/rpcs3qt/cheat_manager.cpp | 16 +++---- rpcs3/util/atomic.hpp | 44 +++++++++---------- rpcs3/util/endian.hpp | 6 +-- rpcs3/util/fnv_hash.hpp | 2 +- rpcs3/util/to_endian.hpp | 6 +-- rpcs3/util/types.hpp | 14 +++--- 26 files changed, 111 insertions(+), 107 deletions(-) diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp index d9cbd58d68..8a4f6480b9 100644 --- a/Utilities/StrFmt.cpp +++ b/Utilities/StrFmt.cpp @@ -518,7 +518,7 @@ struct fmt::cfmt_src TYPE(llong); TYPE(schar); TYPE(short); - if (std::is_signed::value) TYPE(char); + if (std::is_signed_v) TYPE(char); TYPE(long); TYPE(s128); diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index 898313ee6b..10671344e2 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -54,7 +54,7 @@ struct fmt_unveil }; template -struct fmt_unveil::value && sizeof(T) <= 8 && alignof(T) <= 8>> +struct fmt_unveil && sizeof(T) <= 8 && alignof(T) <= 8>> { using type = T; @@ -65,7 +65,7 @@ struct fmt_unveil::value && sizeof(T) <= }; template -struct fmt_unveil::value && sizeof(T) <= 8 && alignof(T) <= 8>> +struct fmt_unveil && sizeof(T) <= 8 && alignof(T) <= 8>> { using type = T; @@ -77,7 +77,7 @@ struct fmt_unveil::value && sizeof }; template -struct fmt_unveil::value>> +struct fmt_unveil>> { using type = T; diff --git a/Utilities/bit_set.h b/Utilities/bit_set.h index 8b81929b7c..f418fde13e 100644 --- a/Utilities/bit_set.h +++ b/Utilities/bit_set.h @@ -60,9 +60,9 @@ public: static constexpr usz bitmax = sizeof(T) * 8; static constexpr usz bitsize = static_cast(T::__bitset_enum_max); - static_assert(std::is_enum::value, "bs_t<> error: invalid type (must be enum)"); + static_assert(std::is_enum_v, "bs_t<> error: invalid type (must be enum)"); static_assert(bitsize <= bitmax, "bs_t<> error: invalid __bitset_enum_max"); - static_assert(bitsize != bitmax || std::is_unsigned::value, "bs_t<> error: invalid __bitset_enum_max (sign bit)"); + static_assert(bitsize != bitmax || std::is_unsigned_v, "bs_t<> error: invalid __bitset_enum_max (sign bit)"); // Helper function static constexpr under shift(T value) diff --git a/rpcs3/Emu/CPU/CPUTranslator.h b/rpcs3/Emu/CPU/CPUTranslator.h index 2f4762e7fa..230d517a6d 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.h +++ b/rpcs3/Emu/CPU/CPUTranslator.h @@ -125,7 +125,7 @@ using get_int_vt = typename get_int_bits::utype; template struct llvm_value_t { - static_assert(std::is_same::value, "llvm_value_t<> error: unknown type"); + static_assert(std::is_same_v, "llvm_value_t<> error: unknown type"); using type = void; using base = llvm_value_t; @@ -417,7 +417,7 @@ struct llvm_value_t : llvm_value_t template struct llvm_value_t : llvm_value_t { - static_assert(!std::is_void::value, "llvm_value_t<> error: invalid pointer to void type"); + static_assert(!std::is_void_v, "llvm_value_t<> error: invalid pointer to void type"); using type = T*; using base = llvm_value_t; diff --git a/rpcs3/Emu/Cell/Modules/cellGem.cpp b/rpcs3/Emu/Cell/Modules/cellGem.cpp index 01ae0c55aa..c7867f0acb 100644 --- a/rpcs3/Emu/Cell/Modules/cellGem.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGem.cpp @@ -804,11 +804,11 @@ static void ds3_pos_to_gem_state(u32 gem_num, const gem_config::gem_controller& s32 ds3_pos_x, ds3_pos_y; ds3_get_stick_values(gem_num, pad, ds3_pos_x, ds3_pos_y); - if constexpr (std::is_same>::value) + if constexpr (std::is_same_v>) { pos_to_gem_state(gem_num, controller, gem_state, ds3_pos_x, ds3_pos_y, ds3_max_x, ds3_max_y); } - else if constexpr (std::is_same>::value) + else if constexpr (std::is_same_v>) { pos_to_gem_image_state(gem_num, controller, gem_state, ds3_pos_x, ds3_pos_y, ds3_max_x, ds3_max_y); } @@ -947,11 +947,11 @@ static void mouse_pos_to_gem_state(const u32 mouse_no, const gem_config::gem_con const auto& mouse = ::at32(handler.GetMice(), mouse_no); - if constexpr (std::is_same>::value) + if constexpr (std::is_same_v>) { pos_to_gem_state(mouse_no, controller, gem_state, mouse.x_pos, mouse.y_pos, mouse.x_max, mouse.y_max); } - else if constexpr (std::is_same>::value) + else if constexpr (std::is_same_v>) { pos_to_gem_image_state(mouse_no, controller, gem_state, mouse.x_pos, mouse.y_pos, mouse.x_max, mouse.y_max); } @@ -1015,11 +1015,11 @@ static void gun_pos_to_gem_state(const u32 gem_no, const gem_config::gem_control y_max = gun.handler.get_axis_y_max(gem_no); } - if constexpr (std::is_same>::value) + if constexpr (std::is_same_v>) { pos_to_gem_state(gem_no, controller, gem_state, x_pos, y_pos, x_max, y_max); } - else if constexpr (std::is_same>::value) + else if constexpr (std::is_same_v>) { pos_to_gem_image_state(gem_no, controller, gem_state, x_pos, y_pos, x_max, y_max); } diff --git a/rpcs3/Emu/Cell/Modules/sceNp.cpp b/rpcs3/Emu/Cell/Modules/sceNp.cpp index 2c185bc566..32fe68c633 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNp.cpp @@ -5834,8 +5834,8 @@ error_code scenp_score_get_ranking_by_npid(s32 transId, SceNpScoreBoardId boardI std::vector> npid_vec; - static constexpr bool is_npid = std::is_same>::value; - static constexpr bool is_npidpcid = std::is_same>::value; + static constexpr bool is_npid = std::is_same_v>; + static constexpr bool is_npidpcid = std::is_same_v>; static_assert(is_npid || is_npidpcid, "T should be vm::cptr or vm::cptr"); if constexpr (is_npid) diff --git a/rpcs3/Emu/Cell/PPUCallback.h b/rpcs3/Emu/Cell/PPUCallback.h index e971436a1e..2a8ff78608 100644 --- a/rpcs3/Emu/Cell/PPUCallback.h +++ b/rpcs3/Emu/Cell/PPUCallback.h @@ -27,8 +27,8 @@ namespace ppu_cb_detail struct _func_arg { static_assert(type == ARG_GENERAL, "Unknown callback argument type"); - static_assert(!std::is_pointer::value, "Invalid callback argument type (pointer)"); - static_assert(!std::is_reference::value, "Invalid callback argument type (reference)"); + static_assert(!std::is_pointer_v, "Invalid callback argument type (pointer)"); + static_assert(!std::is_reference_v, "Invalid callback argument type (reference)"); static_assert(sizeof(T) <= 8, "Invalid callback argument type for ARG_GENERAL"); static inline void set_value(ppu_thread& CPU, const T& arg) @@ -51,7 +51,7 @@ namespace ppu_cb_detail template struct _func_arg { - static_assert(std::is_same, v128>::value, "Invalid callback argument type for ARG_VECTOR"); + static_assert(std::is_same_v, v128>, "Invalid callback argument type for ARG_VECTOR"); static inline void set_value(ppu_thread& CPU, const T& arg) { @@ -75,7 +75,7 @@ namespace ppu_cb_detail template struct _func_arg { - static_assert(std::is_same, ppu_thread>::value, "Invalid callback argument type for ARG_CONTEXT"); + static_assert(std::is_same_v, ppu_thread>, "Invalid callback argument type for ARG_CONTEXT"); FORCE_INLINE static void set_value(ppu_thread&, const T&) { @@ -92,9 +92,9 @@ namespace ppu_cb_detail template FORCE_INLINE static bool _bind_func_args(ppu_thread& CPU, T1 arg1, T... args) { - const bool is_float = std::is_floating_point::value; - const bool is_vector = std::is_same, v128>::value; - const bool is_context = std::is_same, ppu_thread>::value; + const bool is_float = std::is_floating_point_v; + const bool is_vector = std::is_same_v, v128>; + const bool is_context = std::is_same_v, ppu_thread>; const bool is_general = !is_float && !is_vector && !is_context; const _func_arg_type t = @@ -140,7 +140,7 @@ namespace ppu_cb_detail template struct _func_res { - static_assert(std::is_same, v128>::value, "Invalid callback result type for ARG_VECTOR"); + static_assert(std::is_same_v, v128>, "Invalid callback result type for ARG_VECTOR"); FORCE_INLINE static T get_value(const ppu_thread& CPU) { @@ -155,10 +155,10 @@ namespace ppu_cb_detail { _func_caller::call(CPU, pc, rtoc, args...); - static_assert(!std::is_pointer::value, "Invalid callback result type (pointer)"); - static_assert(!std::is_reference::value, "Invalid callback result type (reference)"); - const bool is_float = std::is_floating_point::value; - const bool is_vector = std::is_same, v128>::value; + static_assert(!std::is_pointer_v, "Invalid callback result type (pointer)"); + static_assert(!std::is_reference_v, "Invalid callback result type (reference)"); + const bool is_float = std::is_floating_point_v; + const bool is_vector = std::is_same_v, v128>; const _func_arg_type t = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL); return _func_res::get_value(CPU); diff --git a/rpcs3/Emu/Cell/PPUFunction.h b/rpcs3/Emu/Cell/PPUFunction.h index b53659938d..e9ef4321b9 100644 --- a/rpcs3/Emu/Cell/PPUFunction.h +++ b/rpcs3/Emu/Cell/PPUFunction.h @@ -47,8 +47,8 @@ namespace ppu_func_detail struct bind_arg { static_assert(type == ARG_GENERAL, "Unknown function argument type"); - static_assert(!std::is_pointer::value, "Invalid function argument type (pointer)"); - static_assert(!std::is_reference::value, "Invalid function argument type (reference)"); + static_assert(!std::is_pointer_v, "Invalid function argument type (pointer)"); + static_assert(!std::is_reference_v, "Invalid function argument type (reference)"); static_assert(sizeof(T) <= 8, "Invalid function argument type for ARG_GENERAL"); static inline T get_arg(ppu_thread& ppu) @@ -71,7 +71,7 @@ namespace ppu_func_detail template struct bind_arg { - static_assert(std::is_same, v128>::value, "Invalid function argument type for ARG_VECTOR"); + static_assert(std::is_same_v, v128>, "Invalid function argument type for ARG_VECTOR"); static FORCE_INLINE T get_arg(ppu_thread& ppu) { @@ -93,7 +93,7 @@ namespace ppu_func_detail template struct bind_arg { - static_assert(std::is_base_of, ppu_thread>::value, "Invalid function argument type for ARG_CONTEXT"); + static_assert(std::is_base_of_v, ppu_thread>, "Invalid function argument type for ARG_CONTEXT"); static FORCE_INLINE T& get_arg(ppu_thread& ppu) { @@ -104,7 +104,7 @@ namespace ppu_func_detail template struct bind_arg { - static_assert(std::is_same, ppu_va_args_t>::value, "Invalid function argument type for ARG_VARIADIC"); + static_assert(std::is_same_v, ppu_va_args_t>, "Invalid function argument type for ARG_VARIADIC"); static FORCE_INLINE ppu_va_args_t get_arg(ppu_thread&) { @@ -140,7 +140,7 @@ namespace ppu_func_detail template struct bind_result { - static_assert(std::is_same, v128>::value, "Invalid function result type for ARG_VECTOR"); + static_assert(std::is_same_v, v128>, "Invalid function result type for ARG_VECTOR"); static FORCE_INLINE void put_result(ppu_thread& ppu, const T& result) { @@ -192,10 +192,10 @@ namespace ppu_func_detail const u32 v_count = (info.last_value >> 24); // TODO: check calculations - const bool is_float = std::is_floating_point::value; - const bool is_vector = std::is_same, v128>::value; - const bool is_context = std::is_base_of, ppu_thread>::value; - const bool is_variadic = std::is_same, ppu_va_args_t>::value; + const bool is_float = std::is_floating_point_v; + const bool is_vector = std::is_same_v, v128>; + const bool is_context = std::is_base_of_v, ppu_thread>; + const bool is_variadic = std::is_same_v, ppu_va_args_t>; const bool is_general = !is_float && !is_vector && !is_context && !is_variadic; const arg_class t = @@ -216,10 +216,10 @@ namespace ppu_func_detail template struct result_type { - static_assert(!std::is_pointer::value, "Invalid function result type (pointer)"); - static_assert(!std::is_reference::value, "Invalid function result type (reference)"); - static const bool is_float = std::is_floating_point::value; - static const bool is_vector = std::is_same, v128>::value; + static_assert(!std::is_pointer_v, "Invalid function result type (pointer)"); + static_assert(!std::is_reference_v, "Invalid function result type (reference)"); + static const bool is_float = std::is_floating_point_v; + static const bool is_vector = std::is_same_v, v128>; static const arg_class value = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL); }; diff --git a/rpcs3/Emu/Cell/PPUModule.h b/rpcs3/Emu/Cell/PPUModule.h index daa2d05d14..454694ddcf 100644 --- a/rpcs3/Emu/Cell/PPUModule.h +++ b/rpcs3/Emu/Cell/PPUModule.h @@ -147,7 +147,7 @@ public: { using gvar = std::decay_t; - static_assert(std::is_same::value, "Static variable registration: vm::gvar expected"); + static_assert(std::is_same_v, "Static variable registration: vm::gvar expected"); auto& info = access_static_variable(_module, vnid); diff --git a/rpcs3/Emu/Cell/PPUThread.h b/rpcs3/Emu/Cell/PPUThread.h index c513a0950d..5e7a430fba 100644 --- a/rpcs3/Emu/Cell/PPUThread.h +++ b/rpcs3/Emu/Cell/PPUThread.h @@ -385,10 +385,10 @@ struct ppu_gpr_cast_impl }; template -struct ppu_gpr_cast_impl::value || std::is_enum::value>> +struct ppu_gpr_cast_impl || std::is_enum_v>> { static_assert(sizeof(T) <= 8, "Too big integral type for ppu_gpr_cast<>()"); - static_assert(std::is_same, bool>::value == false, "bool type is deprecated in ppu_gpr_cast<>(), use b8 instead"); + static_assert(std::is_same_v, bool> == false, "bool type is deprecated in ppu_gpr_cast<>(), use b8 instead"); static inline u64 to(const T& value) { diff --git a/rpcs3/Emu/IdManager.h b/rpcs3/Emu/IdManager.h index a5f4e2a7b2..2b5b05fc5b 100644 --- a/rpcs3/Emu/IdManager.h +++ b/rpcs3/Emu/IdManager.h @@ -488,7 +488,7 @@ class idm if (data.second) { - if (std::is_same::value || data.first.type() == get_type()) + if (std::is_same_v || data.first.type() == get_type()) { if (!id_manager::id_traits::invl_range.second || data.first.value() == id) { diff --git a/rpcs3/Emu/Memory/vm_ptr.h b/rpcs3/Emu/Memory/vm_ptr.h index 35b5a9f9c0..3b0e910627 100644 --- a/rpcs3/Emu/Memory/vm_ptr.h +++ b/rpcs3/Emu/Memory/vm_ptr.h @@ -22,8 +22,8 @@ namespace vm { AT m_addr; - static_assert(!std::is_pointer::value, "vm::_ptr_base<> error: invalid type (pointer)"); - static_assert(!std::is_reference::value, "vm::_ptr_base<> error: invalid type (reference)"); + static_assert(!std::is_pointer_v, "vm::_ptr_base<> error: invalid type (pointer)"); + static_assert(!std::is_reference_v, "vm::_ptr_base<> error: invalid type (reference)"); public: using type = T; diff --git a/rpcs3/Emu/Memory/vm_ref.h b/rpcs3/Emu/Memory/vm_ref.h index 4e792b9f55..5abded43b0 100644 --- a/rpcs3/Emu/Memory/vm_ref.h +++ b/rpcs3/Emu/Memory/vm_ref.h @@ -20,10 +20,10 @@ namespace vm { AT m_addr; - static_assert(!std::is_pointer::value, "vm::_ref_base<> error: invalid type (pointer)"); - static_assert(!std::is_reference::value, "vm::_ref_base<> error: invalid type (reference)"); - static_assert(!std::is_function::value, "vm::_ref_base<> error: invalid type (function)"); - static_assert(!std::is_void::value, "vm::_ref_base<> error: invalid type (void)"); + static_assert(!std::is_pointer_v, "vm::_ref_base<> error: invalid type (pointer)"); + static_assert(!std::is_reference_v, "vm::_ref_base<> error: invalid type (reference)"); + static_assert(!std::is_function_v, "vm::_ref_base<> error: invalid type (function)"); + static_assert(!std::is_void_v, "vm::_ref_base<> error: invalid type (void)"); public: using type = T; diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index 340f82641e..ba19fdb461 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.cpp +++ b/rpcs3/Emu/RSX/Common/BufferUtils.cpp @@ -435,7 +435,7 @@ std::tuple upload_untouched(std::span> src, std::spa { return untouched_impl::upload_untouched(src, dst); } - else if constexpr (std::is_same::value) + else if constexpr (std::is_same_v) { if (primitive_restart_index > 0xffff) { diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index f940c83062..2d02f6f468 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -224,7 +224,7 @@ struct copy_unmodified_block_swizzled template static void copy_mipmap_level(std::span dst, std::span src, u16 words_per_block, u16 width_in_block, u16 row_count, u16 depth, u8 border, u32 dst_pitch_in_block) { - if (std::is_same::value && dst_pitch_in_block == width_in_block && words_per_block == 1 && !border) + if (std::is_same_v && dst_pitch_in_block == width_in_block && words_per_block == 1 && !border) { rsx::convert_linear_swizzle_3d(src.data(), dst.data(), width_in_block, row_count, depth); } diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index 9c5bab5f95..d314356a6c 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -1,5 +1,8 @@ #pragma once +#include "Emu/RSX/Common/simple_array.hpp" +#include "Emu/RSX/Core/RSXContext.h" +#include "Emu/RSX/RSXThread.h" #include "texture_cache_utils.h" #include "texture_cache_predictor.h" #include "texture_cache_helpers.h" @@ -35,7 +38,7 @@ namespace rsx using copy_region_descriptor = copy_region_descriptor_base; private: - static_assert(std::is_base_of, section_storage_type>::value, "section_storage_type must derive from rsx::cached_texture_section"); + static_assert(std::is_base_of_v, section_storage_type>, "section_storage_type must derive from rsx::cached_texture_section"); /** * Helper structs/enums diff --git a/rpcs3/Emu/RSX/Core/RSXContext.h b/rpcs3/Emu/RSX/Core/RSXContext.h index c61529e4ff..3b69d569aa 100644 --- a/rpcs3/Emu/RSX/Core/RSXContext.h +++ b/rpcs3/Emu/RSX/Core/RSXContext.h @@ -3,6 +3,7 @@ #include #include "Emu/Cell/lv2/sys_rsx.h" #include "Emu/RSX/GCM.h" +#include "Emu/RSX/rsx_utils.h" #include "RSXIOMap.hpp" namespace rsx diff --git a/rpcs3/Emu/RSX/Overlays/HomeMenu/overlay_home_menu_components.h b/rpcs3/Emu/RSX/Overlays/HomeMenu/overlay_home_menu_components.h index f35f1f2fc7..644402bc3d 100644 --- a/rpcs3/Emu/RSX/Overlays/HomeMenu/overlay_home_menu_components.h +++ b/rpcs3/Emu/RSX/Overlays/HomeMenu/overlay_home_menu_components.h @@ -157,7 +157,7 @@ namespace rsx return; } - if constexpr (std::is_floating_point::value) + if constexpr (std::is_floating_point_v) { m_value_label.set_text(fmt::format("%.2f%s", this->m_last_value, m_suffix)); } diff --git a/rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.cpp b/rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.cpp index 1408bd636c..97d482e78e 100644 --- a/rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/Program/FragmentProgramDecompiler.cpp @@ -497,15 +497,15 @@ template std::string FragmentProgramDecompiler::GetSRC(T src) std::string ret; u32 precision_modifier = 0; - if constexpr (std::is_same::value) + if constexpr (std::is_same_v) { precision_modifier = src1.src0_prec_mod; } - else if constexpr (std::is_same::value) + else if constexpr (std::is_same_v) { precision_modifier = src1.src1_prec_mod; } - else if constexpr (std::is_same::value) + else if constexpr (std::is_same_v) { precision_modifier = src1.src2_prec_mod; } diff --git a/rpcs3/Loader/ELF.h b/rpcs3/Loader/ELF.h index 1090fb30ef..ec6e3a5ece 100644 --- a/rpcs3/Loader/ELF.h +++ b/rpcs3/Loader/ELF.h @@ -288,11 +288,11 @@ public: return set_error(elf_error::header_magic); // Check class - if (header.e_class != (std::is_same::value ? 1 : 2)) + if (header.e_class != (std::is_same_v ? 1 : 2)) return set_error(elf_error::header_class); // Check endianness - if (header.e_data != (std::is_same, le_t>::value ? 1 : 2)) + if (header.e_data != (std::is_same_v, le_t> ? 1 : 2)) return set_error(elf_error::header_endianness); // Check machine @@ -413,8 +413,8 @@ public: // Write header ehdr_t header{}; header.e_magic = "\177ELF"_u32; - header.e_class = std::is_same::value ? 1 : 2; - header.e_data = std::is_same, le_t>::value ? 1 : 2; + header.e_class = std::is_same_v ? 1 : 2; + header.e_data = std::is_same_v, le_t> ? 1 : 2; header.e_curver = 1; header.e_os_abi = OS != elf_os::none ? OS : this->header.e_os_abi; header.e_abi_ver = this->header.e_abi_ver; diff --git a/rpcs3/rpcs3qt/cheat_manager.cpp b/rpcs3/rpcs3qt/cheat_manager.cpp index 36f797c932..5fa0d60ba6 100644 --- a/rpcs3/rpcs3qt/cheat_manager.cpp +++ b/rpcs3/rpcs3qt/cheat_manager.cpp @@ -889,7 +889,7 @@ T cheat_manager_dialog::convert_from_QString(const QString& str, bool& success) { T result; - if constexpr (std::is_same::value) + if constexpr (std::is_same_v) { const u16 result_16 = str.toUShort(&success); @@ -899,16 +899,16 @@ T cheat_manager_dialog::convert_from_QString(const QString& str, bool& success) result = static_cast(result_16); } - if constexpr (std::is_same::value) + if constexpr (std::is_same_v) result = str.toUShort(&success); - if constexpr (std::is_same::value) + if constexpr (std::is_same_v) result = str.toUInt(&success); - if constexpr (std::is_same::value) + if constexpr (std::is_same_v) result = str.toULongLong(&success); - if constexpr (std::is_same::value) + if constexpr (std::is_same_v) { const s16 result_16 = str.toShort(&success); if (result_16 < -128 || result_16 > 127) @@ -917,13 +917,13 @@ T cheat_manager_dialog::convert_from_QString(const QString& str, bool& success) result = static_cast(result_16); } - if constexpr (std::is_same::value) + if constexpr (std::is_same_v) result = str.toShort(&success); - if constexpr (std::is_same::value) + if constexpr (std::is_same_v) result = str.toInt(&success); - if constexpr (std::is_same::value) + if constexpr (std::is_same_v) result = str.toLongLong(&success); return result; diff --git a/rpcs3/util/atomic.hpp b/rpcs3/util/atomic.hpp index e843b1119f..85e366943b 100644 --- a/rpcs3/util/atomic.hpp +++ b/rpcs3/util/atomic.hpp @@ -1338,7 +1338,7 @@ public: auto fetch_add(const ptr_rt& rhs) { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::fetch_add(m_data, rhs); } @@ -1351,7 +1351,7 @@ public: auto add_fetch(const ptr_rt& rhs) { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::add_fetch(m_data, rhs); } @@ -1365,7 +1365,7 @@ public: auto operator +=(const ptr_rt& rhs) { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::add_fetch(m_data, rhs); } @@ -1378,7 +1378,7 @@ public: auto fetch_sub(const ptr_rt& rhs) { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::fetch_sub(m_data, rhs); } @@ -1391,7 +1391,7 @@ public: auto sub_fetch(const ptr_rt& rhs) { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::sub_fetch(m_data, rhs); } @@ -1405,7 +1405,7 @@ public: auto operator -=(const ptr_rt& rhs) { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::sub_fetch(m_data, rhs); } @@ -1418,7 +1418,7 @@ public: auto fetch_and(const type& rhs) { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::fetch_and(m_data, rhs); } @@ -1431,7 +1431,7 @@ public: auto and_fetch(const type& rhs) { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::and_fetch(m_data, rhs); } @@ -1445,7 +1445,7 @@ public: auto operator &=(const type& rhs) { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::and_fetch(m_data, rhs); } @@ -1458,7 +1458,7 @@ public: auto fetch_or(const type& rhs) { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::fetch_or(m_data, rhs); } @@ -1471,7 +1471,7 @@ public: auto or_fetch(const type& rhs) { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::or_fetch(m_data, rhs); } @@ -1485,7 +1485,7 @@ public: auto operator |=(const type& rhs) { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::or_fetch(m_data, rhs); } @@ -1498,7 +1498,7 @@ public: auto fetch_xor(const type& rhs) { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::fetch_xor(m_data, rhs); } @@ -1511,7 +1511,7 @@ public: auto xor_fetch(const type& rhs) { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::xor_fetch(m_data, rhs); } @@ -1525,7 +1525,7 @@ public: auto operator ^=(const type& rhs) { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::xor_fetch(m_data, rhs); } @@ -1538,7 +1538,7 @@ public: auto operator ++() { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::inc_fetch(m_data); } @@ -1551,7 +1551,7 @@ public: auto operator --() { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::dec_fetch(m_data); } @@ -1564,7 +1564,7 @@ public: auto operator ++(int) { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::fetch_inc(m_data); } @@ -1577,7 +1577,7 @@ public: auto operator --(int) { - if constexpr(std::is_integral::value) + if constexpr(std::is_integral_v) { return atomic_storage::fetch_dec(m_data); } @@ -1636,7 +1636,7 @@ public: bool bit_test_set(uint bit) { - if constexpr (std::is_integral::value) + if constexpr (std::is_integral_v) { return atomic_storage::bts(m_data, bit & (sizeof(T) * 8 - 1)); } @@ -1652,7 +1652,7 @@ public: bool bit_test_reset(uint bit) { - if constexpr (std::is_integral::value) + if constexpr (std::is_integral_v) { return atomic_storage::btr(m_data, bit & (sizeof(T) * 8 - 1)); } @@ -1668,7 +1668,7 @@ public: bool bit_test_invert(uint bit) { - if constexpr (std::is_integral::value) + if constexpr (std::is_integral_v) { return atomic_storage::btc(m_data, bit & (sizeof(T) * 8 - 1)); } diff --git a/rpcs3/util/endian.hpp b/rpcs3/util/endian.hpp index c001419ea1..009ccbaf6c 100644 --- a/rpcs3/util/endian.hpp +++ b/rpcs3/util/endian.hpp @@ -154,9 +154,9 @@ namespace stx stype m_data; - static_assert(!std::is_pointer::value, "se_t<> error: invalid type (pointer)"); - static_assert(!std::is_reference::value, "se_t<> error: invalid type (reference)"); - static_assert(!std::is_array::value, "se_t<> error: invalid type (array)"); + static_assert(!std::is_pointer_v, "se_t<> error: invalid type (pointer)"); + static_assert(!std::is_reference_v, "se_t<> error: invalid type (reference)"); + static_assert(!std::is_array_v, "se_t<> error: invalid type (array)"); static_assert(sizeof(type) == alignof(type), "se_t<> error: unexpected alignment"); static constexpr stype to_data(type value) noexcept diff --git a/rpcs3/util/fnv_hash.hpp b/rpcs3/util/fnv_hash.hpp index d7ebfe74da..42ff84abe2 100644 --- a/rpcs3/util/fnv_hash.hpp +++ b/rpcs3/util/fnv_hash.hpp @@ -14,7 +14,7 @@ namespace rpcs3 return static_cast(value); } - template ::value>> + template >> static inline usz hash64(usz hash_value, T data) { hash_value ^= data; diff --git a/rpcs3/util/to_endian.hpp b/rpcs3/util/to_endian.hpp index 710c755a30..6bd101ace0 100644 --- a/rpcs3/util/to_endian.hpp +++ b/rpcs3/util/to_endian.hpp @@ -16,7 +16,7 @@ struct to_se }; template - struct to_se_::value || std::is_enum::value>> + struct to_se_ || std::is_enum_v>> { using type = std::conditional_t<(sizeof(T2) > 1), se_t, T2>; }; @@ -44,14 +44,14 @@ struct to_se }; template -struct to_se::value>> +struct to_se>> { // Move const qualifier using type = const typename to_se::type; }; template -struct to_se::value && !std::is_const::value>> +struct to_se && !std::is_const_v>> { // Move volatile qualifier using type = volatile typename to_se::type; diff --git a/rpcs3/util/types.hpp b/rpcs3/util/types.hpp index 47eb08147f..549dc0ded4 100644 --- a/rpcs3/util/types.hpp +++ b/rpcs3/util/types.hpp @@ -752,7 +752,7 @@ inline u32 offset32(T T2::*const mptr) template struct offset32_array { - static_assert(std::is_array::value, "Invalid pointer-to-member type (array expected)"); + static_assert(std::is_array_v, "Invalid pointer-to-member type (array expected)"); template static inline u32 index32(const Arg& arg) @@ -956,7 +956,7 @@ template struct narrow_impl { // Temporarily (diagnostic) - static_assert(std::is_void::value, "narrow_impl<> specialization not found"); + static_assert(std::is_void_v, "narrow_impl<> specialization not found"); // Returns true if value cannot be represented in type To static constexpr bool test(const From&) @@ -968,7 +968,7 @@ struct narrow_impl // Unsigned to unsigned narrowing template -struct narrow_impl::value && std::is_unsigned::value>> +struct narrow_impl && std::is_unsigned_v>> { static constexpr bool test(const From& value) { @@ -978,7 +978,7 @@ struct narrow_impl::value && s // Signed to signed narrowing template -struct narrow_impl::value && std::is_signed::value>> +struct narrow_impl && std::is_signed_v>> { static constexpr bool test(const From& value) { @@ -988,7 +988,7 @@ struct narrow_impl::value && std // Unsigned to signed narrowing template -struct narrow_impl::value && std::is_signed::value>> +struct narrow_impl && std::is_signed_v>> { static constexpr bool test(const From& value) { @@ -998,7 +998,7 @@ struct narrow_impl::value && s // Signed to unsigned narrowing (I) template -struct narrow_impl::value && std::is_unsigned::value && sizeof(To) >= sizeof(From)>> +struct narrow_impl && std::is_unsigned_v && sizeof(To) >= sizeof(From)>> { static constexpr bool test(const From& value) { @@ -1008,7 +1008,7 @@ struct narrow_impl::value && std // Signed to unsigned narrowing (II) template -struct narrow_impl::value && std::is_unsigned::value && sizeof(To) < sizeof(From)>> +struct narrow_impl && std::is_unsigned_v && sizeof(To) < sizeof(From)>> { static constexpr bool test(const From& value) {