1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-24 03:32:50 +01:00

simplify template code like std::is_same<T>::value

This commit is contained in:
oltolm 2024-03-20 17:16:49 +01:00 committed by Elad Ashkenazi
parent c268189e38
commit 9e9a3262eb
26 changed files with 111 additions and 107 deletions

View File

@ -518,7 +518,7 @@ struct fmt::cfmt_src
TYPE(llong); TYPE(llong);
TYPE(schar); TYPE(schar);
TYPE(short); TYPE(short);
if (std::is_signed<char>::value) TYPE(char); if (std::is_signed_v<char>) TYPE(char);
TYPE(long); TYPE(long);
TYPE(s128); TYPE(s128);

View File

@ -54,7 +54,7 @@ struct fmt_unveil
}; };
template <typename T> template <typename T>
struct fmt_unveil<T, std::enable_if_t<std::is_integral<T>::value && sizeof(T) <= 8 && alignof(T) <= 8>> struct fmt_unveil<T, std::enable_if_t<std::is_integral_v<T> && sizeof(T) <= 8 && alignof(T) <= 8>>
{ {
using type = T; using type = T;
@ -65,7 +65,7 @@ struct fmt_unveil<T, std::enable_if_t<std::is_integral<T>::value && sizeof(T) <=
}; };
template <typename T> template <typename T>
struct fmt_unveil<T, std::enable_if_t<std::is_floating_point<T>::value && sizeof(T) <= 8 && alignof(T) <= 8>> struct fmt_unveil<T, std::enable_if_t<std::is_floating_point_v<T> && sizeof(T) <= 8 && alignof(T) <= 8>>
{ {
using type = T; using type = T;
@ -77,7 +77,7 @@ struct fmt_unveil<T, std::enable_if_t<std::is_floating_point<T>::value && sizeof
}; };
template <typename T> template <typename T>
struct fmt_unveil<T, std::enable_if_t<std::is_enum<T>::value>> struct fmt_unveil<T, std::enable_if_t<std::is_enum_v<T>>>
{ {
using type = T; using type = T;

View File

@ -60,9 +60,9 @@ public:
static constexpr usz bitmax = sizeof(T) * 8; static constexpr usz bitmax = sizeof(T) * 8;
static constexpr usz bitsize = static_cast<under>(T::__bitset_enum_max); static constexpr usz bitsize = static_cast<under>(T::__bitset_enum_max);
static_assert(std::is_enum<T>::value, "bs_t<> error: invalid type (must be enum)"); static_assert(std::is_enum_v<T>, "bs_t<> error: invalid type (must be enum)");
static_assert(bitsize <= bitmax, "bs_t<> error: invalid __bitset_enum_max"); static_assert(bitsize <= bitmax, "bs_t<> error: invalid __bitset_enum_max");
static_assert(bitsize != bitmax || std::is_unsigned<under>::value, "bs_t<> error: invalid __bitset_enum_max (sign bit)"); static_assert(bitsize != bitmax || std::is_unsigned_v<under>, "bs_t<> error: invalid __bitset_enum_max (sign bit)");
// Helper function // Helper function
static constexpr under shift(T value) static constexpr under shift(T value)

View File

@ -125,7 +125,7 @@ using get_int_vt = typename get_int_bits<Bits>::utype;
template <typename T = void> template <typename T = void>
struct llvm_value_t struct llvm_value_t
{ {
static_assert(std::is_same<T, void>::value, "llvm_value_t<> error: unknown type"); static_assert(std::is_same_v<T, void>, "llvm_value_t<> error: unknown type");
using type = void; using type = void;
using base = llvm_value_t; using base = llvm_value_t;
@ -417,7 +417,7 @@ struct llvm_value_t<f64> : llvm_value_t<void>
template <typename T> template <typename T>
struct llvm_value_t<T*> : llvm_value_t<T> struct llvm_value_t<T*> : llvm_value_t<T>
{ {
static_assert(!std::is_void<T>::value, "llvm_value_t<> error: invalid pointer to void type"); static_assert(!std::is_void_v<T>, "llvm_value_t<> error: invalid pointer to void type");
using type = T*; using type = T*;
using base = llvm_value_t<T>; using base = llvm_value_t<T>;

View File

@ -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; s32 ds3_pos_x, ds3_pos_y;
ds3_get_stick_values(gem_num, pad, ds3_pos_x, ds3_pos_y); ds3_get_stick_values(gem_num, pad, ds3_pos_x, ds3_pos_y);
if constexpr (std::is_same<T, vm::ptr<CellGemState>>::value) if constexpr (std::is_same_v<T, vm::ptr<CellGemState>>)
{ {
pos_to_gem_state(gem_num, controller, gem_state, ds3_pos_x, ds3_pos_y, ds3_max_x, ds3_max_y); 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<T, vm::ptr<CellGemImageState>>::value) else if constexpr (std::is_same_v<T, vm::ptr<CellGemImageState>>)
{ {
pos_to_gem_image_state(gem_num, controller, gem_state, ds3_pos_x, ds3_pos_y, ds3_max_x, ds3_max_y); 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); const auto& mouse = ::at32(handler.GetMice(), mouse_no);
if constexpr (std::is_same<T, vm::ptr<CellGemState>>::value) if constexpr (std::is_same_v<T, vm::ptr<CellGemState>>)
{ {
pos_to_gem_state(mouse_no, controller, gem_state, mouse.x_pos, mouse.y_pos, mouse.x_max, mouse.y_max); 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<T, vm::ptr<CellGemImageState>>::value) else if constexpr (std::is_same_v<T, vm::ptr<CellGemImageState>>)
{ {
pos_to_gem_image_state(mouse_no, controller, gem_state, mouse.x_pos, mouse.y_pos, mouse.x_max, mouse.y_max); 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); y_max = gun.handler.get_axis_y_max(gem_no);
} }
if constexpr (std::is_same<T, vm::ptr<CellGemState>>::value) if constexpr (std::is_same_v<T, vm::ptr<CellGemState>>)
{ {
pos_to_gem_state(gem_no, controller, gem_state, x_pos, y_pos, x_max, y_max); pos_to_gem_state(gem_no, controller, gem_state, x_pos, y_pos, x_max, y_max);
} }
else if constexpr (std::is_same<T, vm::ptr<CellGemImageState>>::value) else if constexpr (std::is_same_v<T, vm::ptr<CellGemImageState>>)
{ {
pos_to_gem_image_state(gem_no, controller, gem_state, x_pos, y_pos, x_max, y_max); pos_to_gem_image_state(gem_no, controller, gem_state, x_pos, y_pos, x_max, y_max);
} }

View File

@ -5834,8 +5834,8 @@ error_code scenp_score_get_ranking_by_npid(s32 transId, SceNpScoreBoardId boardI
std::vector<std::pair<SceNpId, s32>> npid_vec; std::vector<std::pair<SceNpId, s32>> npid_vec;
static constexpr bool is_npid = std::is_same<T, vm::cptr<SceNpId>>::value; static constexpr bool is_npid = std::is_same_v<T, vm::cptr<SceNpId>>;
static constexpr bool is_npidpcid = std::is_same<T, vm::cptr<SceNpScoreNpIdPcId>>::value; static constexpr bool is_npidpcid = std::is_same_v<T, vm::cptr<SceNpScoreNpIdPcId>>;
static_assert(is_npid || is_npidpcid, "T should be vm::cptr<SceNpId> or vm::cptr<SceNpScoreNpIdPcId>"); static_assert(is_npid || is_npidpcid, "T should be vm::cptr<SceNpId> or vm::cptr<SceNpScoreNpIdPcId>");
if constexpr (is_npid) if constexpr (is_npid)

View File

@ -27,8 +27,8 @@ namespace ppu_cb_detail
struct _func_arg struct _func_arg
{ {
static_assert(type == ARG_GENERAL, "Unknown callback argument type"); static_assert(type == ARG_GENERAL, "Unknown callback argument type");
static_assert(!std::is_pointer<T>::value, "Invalid callback argument type (pointer)"); static_assert(!std::is_pointer_v<T>, "Invalid callback argument type (pointer)");
static_assert(!std::is_reference<T>::value, "Invalid callback argument type (reference)"); static_assert(!std::is_reference_v<T>, "Invalid callback argument type (reference)");
static_assert(sizeof(T) <= 8, "Invalid callback argument type for ARG_GENERAL"); static_assert(sizeof(T) <= 8, "Invalid callback argument type for ARG_GENERAL");
static inline void set_value(ppu_thread& CPU, const T& arg) static inline void set_value(ppu_thread& CPU, const T& arg)
@ -51,7 +51,7 @@ namespace ppu_cb_detail
template<typename T, u32 g_count, u32 f_count, u32 v_count> template<typename T, u32 g_count, u32 f_count, u32 v_count>
struct _func_arg<T, ARG_VECTOR, g_count, f_count, v_count> struct _func_arg<T, ARG_VECTOR, g_count, f_count, v_count>
{ {
static_assert(std::is_same<std::decay_t<T>, v128>::value, "Invalid callback argument type for ARG_VECTOR"); static_assert(std::is_same_v<std::decay_t<T>, v128>, "Invalid callback argument type for ARG_VECTOR");
static inline void set_value(ppu_thread& CPU, const T& arg) static inline void set_value(ppu_thread& CPU, const T& arg)
{ {
@ -75,7 +75,7 @@ namespace ppu_cb_detail
template<typename T, u32 g_count, u32 f_count, u32 v_count> template<typename T, u32 g_count, u32 f_count, u32 v_count>
struct _func_arg<T, ARG_CONTEXT, g_count, f_count, v_count> struct _func_arg<T, ARG_CONTEXT, g_count, f_count, v_count>
{ {
static_assert(std::is_same<std::decay_t<T>, ppu_thread>::value, "Invalid callback argument type for ARG_CONTEXT"); static_assert(std::is_same_v<std::decay_t<T>, ppu_thread>, "Invalid callback argument type for ARG_CONTEXT");
FORCE_INLINE static void set_value(ppu_thread&, const T&) FORCE_INLINE static void set_value(ppu_thread&, const T&)
{ {
@ -92,9 +92,9 @@ namespace ppu_cb_detail
template<u32 g_count, u32 f_count, u32 v_count, typename T1, typename... T> template<u32 g_count, u32 f_count, u32 v_count, typename T1, typename... T>
FORCE_INLINE static bool _bind_func_args(ppu_thread& CPU, T1 arg1, T... args) FORCE_INLINE static bool _bind_func_args(ppu_thread& CPU, T1 arg1, T... args)
{ {
const bool is_float = std::is_floating_point<T1>::value; const bool is_float = std::is_floating_point_v<T1>;
const bool is_vector = std::is_same<std::decay_t<T1>, v128>::value; const bool is_vector = std::is_same_v<std::decay_t<T1>, v128>;
const bool is_context = std::is_same<std::decay_t<T1>, ppu_thread>::value; const bool is_context = std::is_same_v<std::decay_t<T1>, ppu_thread>;
const bool is_general = !is_float && !is_vector && !is_context; const bool is_general = !is_float && !is_vector && !is_context;
const _func_arg_type t = const _func_arg_type t =
@ -140,7 +140,7 @@ namespace ppu_cb_detail
template<typename T> template<typename T>
struct _func_res<T, ARG_VECTOR> struct _func_res<T, ARG_VECTOR>
{ {
static_assert(std::is_same<std::decay_t<T>, v128>::value, "Invalid callback result type for ARG_VECTOR"); static_assert(std::is_same_v<std::decay_t<T>, v128>, "Invalid callback result type for ARG_VECTOR");
FORCE_INLINE static T get_value(const ppu_thread& CPU) FORCE_INLINE static T get_value(const ppu_thread& CPU)
{ {
@ -155,10 +155,10 @@ namespace ppu_cb_detail
{ {
_func_caller<void, T...>::call(CPU, pc, rtoc, args...); _func_caller<void, T...>::call(CPU, pc, rtoc, args...);
static_assert(!std::is_pointer<RT>::value, "Invalid callback result type (pointer)"); static_assert(!std::is_pointer_v<RT>, "Invalid callback result type (pointer)");
static_assert(!std::is_reference<RT>::value, "Invalid callback result type (reference)"); static_assert(!std::is_reference_v<RT>, "Invalid callback result type (reference)");
const bool is_float = std::is_floating_point<RT>::value; const bool is_float = std::is_floating_point_v<RT>;
const bool is_vector = std::is_same<std::decay_t<RT>, v128>::value; const bool is_vector = std::is_same_v<std::decay_t<RT>, v128>;
const _func_arg_type t = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL); const _func_arg_type t = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL);
return _func_res<RT, t>::get_value(CPU); return _func_res<RT, t>::get_value(CPU);

View File

@ -47,8 +47,8 @@ namespace ppu_func_detail
struct bind_arg struct bind_arg
{ {
static_assert(type == ARG_GENERAL, "Unknown function argument type"); static_assert(type == ARG_GENERAL, "Unknown function argument type");
static_assert(!std::is_pointer<T>::value, "Invalid function argument type (pointer)"); static_assert(!std::is_pointer_v<T>, "Invalid function argument type (pointer)");
static_assert(!std::is_reference<T>::value, "Invalid function argument type (reference)"); static_assert(!std::is_reference_v<T>, "Invalid function argument type (reference)");
static_assert(sizeof(T) <= 8, "Invalid function argument type for ARG_GENERAL"); static_assert(sizeof(T) <= 8, "Invalid function argument type for ARG_GENERAL");
static inline T get_arg(ppu_thread& ppu) static inline T get_arg(ppu_thread& ppu)
@ -71,7 +71,7 @@ namespace ppu_func_detail
template<typename T, u32 g_count, u32 f_count, u32 v_count> template<typename T, u32 g_count, u32 f_count, u32 v_count>
struct bind_arg<T, ARG_VECTOR, g_count, f_count, v_count> struct bind_arg<T, ARG_VECTOR, g_count, f_count, v_count>
{ {
static_assert(std::is_same<std::decay_t<T>, v128>::value, "Invalid function argument type for ARG_VECTOR"); static_assert(std::is_same_v<std::decay_t<T>, v128>, "Invalid function argument type for ARG_VECTOR");
static FORCE_INLINE T get_arg(ppu_thread& ppu) static FORCE_INLINE T get_arg(ppu_thread& ppu)
{ {
@ -93,7 +93,7 @@ namespace ppu_func_detail
template<typename T, u32 g_count, u32 f_count, u32 v_count> template<typename T, u32 g_count, u32 f_count, u32 v_count>
struct bind_arg<T, ARG_CONTEXT, g_count, f_count, v_count> struct bind_arg<T, ARG_CONTEXT, g_count, f_count, v_count>
{ {
static_assert(std::is_base_of<std::decay_t<T>, ppu_thread>::value, "Invalid function argument type for ARG_CONTEXT"); static_assert(std::is_base_of_v<std::decay_t<T>, ppu_thread>, "Invalid function argument type for ARG_CONTEXT");
static FORCE_INLINE T& get_arg(ppu_thread& ppu) static FORCE_INLINE T& get_arg(ppu_thread& ppu)
{ {
@ -104,7 +104,7 @@ namespace ppu_func_detail
template<typename T, u32 g_count, u32 f_count, u32 v_count> template<typename T, u32 g_count, u32 f_count, u32 v_count>
struct bind_arg<T, ARG_VARIADIC, g_count, f_count, v_count> struct bind_arg<T, ARG_VARIADIC, g_count, f_count, v_count>
{ {
static_assert(std::is_same<std::decay_t<T>, ppu_va_args_t>::value, "Invalid function argument type for ARG_VARIADIC"); static_assert(std::is_same_v<std::decay_t<T>, ppu_va_args_t>, "Invalid function argument type for ARG_VARIADIC");
static FORCE_INLINE ppu_va_args_t get_arg(ppu_thread&) static FORCE_INLINE ppu_va_args_t get_arg(ppu_thread&)
{ {
@ -140,7 +140,7 @@ namespace ppu_func_detail
template<typename T> template<typename T>
struct bind_result<T, ARG_VECTOR> struct bind_result<T, ARG_VECTOR>
{ {
static_assert(std::is_same<std::decay_t<T>, v128>::value, "Invalid function result type for ARG_VECTOR"); static_assert(std::is_same_v<std::decay_t<T>, v128>, "Invalid function result type for ARG_VECTOR");
static FORCE_INLINE void put_result(ppu_thread& ppu, const T& result) 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); const u32 v_count = (info.last_value >> 24);
// TODO: check calculations // TODO: check calculations
const bool is_float = std::is_floating_point<T>::value; const bool is_float = std::is_floating_point_v<T>;
const bool is_vector = std::is_same<std::decay_t<T>, v128>::value; const bool is_vector = std::is_same_v<std::decay_t<T>, v128>;
const bool is_context = std::is_base_of<std::decay_t<T>, ppu_thread>::value; const bool is_context = std::is_base_of_v<std::decay_t<T>, ppu_thread>;
const bool is_variadic = std::is_same<std::decay_t<T>, ppu_va_args_t>::value; const bool is_variadic = std::is_same_v<std::decay_t<T>, ppu_va_args_t>;
const bool is_general = !is_float && !is_vector && !is_context && !is_variadic; const bool is_general = !is_float && !is_vector && !is_context && !is_variadic;
const arg_class t = const arg_class t =
@ -216,10 +216,10 @@ namespace ppu_func_detail
template<typename RT> template<typename RT>
struct result_type struct result_type
{ {
static_assert(!std::is_pointer<RT>::value, "Invalid function result type (pointer)"); static_assert(!std::is_pointer_v<RT>, "Invalid function result type (pointer)");
static_assert(!std::is_reference<RT>::value, "Invalid function result type (reference)"); static_assert(!std::is_reference_v<RT>, "Invalid function result type (reference)");
static const bool is_float = std::is_floating_point<RT>::value; static const bool is_float = std::is_floating_point_v<RT>;
static const bool is_vector = std::is_same<std::decay_t<RT>, v128>::value; static const bool is_vector = std::is_same_v<std::decay_t<RT>, v128>;
static const arg_class value = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL); static const arg_class value = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL);
}; };

View File

@ -147,7 +147,7 @@ public:
{ {
using gvar = std::decay_t<decltype(*Var)>; using gvar = std::decay_t<decltype(*Var)>;
static_assert(std::is_same<u32, typename gvar::addr_type>::value, "Static variable registration: vm::gvar<T> expected"); static_assert(std::is_same_v<u32, typename gvar::addr_type>, "Static variable registration: vm::gvar<T> expected");
auto& info = access_static_variable(_module, vnid); auto& info = access_static_variable(_module, vnid);

View File

@ -385,10 +385,10 @@ struct ppu_gpr_cast_impl
}; };
template<typename T> template<typename T>
struct ppu_gpr_cast_impl<T, std::enable_if_t<std::is_integral<T>::value || std::is_enum<T>::value>> struct ppu_gpr_cast_impl<T, std::enable_if_t<std::is_integral_v<T> || std::is_enum_v<T>>>
{ {
static_assert(sizeof(T) <= 8, "Too big integral type for ppu_gpr_cast<>()"); static_assert(sizeof(T) <= 8, "Too big integral type for ppu_gpr_cast<>()");
static_assert(std::is_same<std::decay_t<T>, bool>::value == false, "bool type is deprecated in ppu_gpr_cast<>(), use b8 instead"); static_assert(std::is_same_v<std::decay_t<T>, bool> == false, "bool type is deprecated in ppu_gpr_cast<>(), use b8 instead");
static inline u64 to(const T& value) static inline u64 to(const T& value)
{ {

View File

@ -488,7 +488,7 @@ class idm
if (data.second) if (data.second)
{ {
if (std::is_same<T, Type>::value || data.first.type() == get_type<Type>()) if (std::is_same_v<T, Type> || data.first.type() == get_type<Type>())
{ {
if (!id_manager::id_traits<Type>::invl_range.second || data.first.value() == id) if (!id_manager::id_traits<Type>::invl_range.second || data.first.value() == id)
{ {

View File

@ -22,8 +22,8 @@ namespace vm
{ {
AT m_addr; AT m_addr;
static_assert(!std::is_pointer<T>::value, "vm::_ptr_base<> error: invalid type (pointer)"); static_assert(!std::is_pointer_v<T>, "vm::_ptr_base<> error: invalid type (pointer)");
static_assert(!std::is_reference<T>::value, "vm::_ptr_base<> error: invalid type (reference)"); static_assert(!std::is_reference_v<T>, "vm::_ptr_base<> error: invalid type (reference)");
public: public:
using type = T; using type = T;

View File

@ -20,10 +20,10 @@ namespace vm
{ {
AT m_addr; AT m_addr;
static_assert(!std::is_pointer<T>::value, "vm::_ref_base<> error: invalid type (pointer)"); static_assert(!std::is_pointer_v<T>, "vm::_ref_base<> error: invalid type (pointer)");
static_assert(!std::is_reference<T>::value, "vm::_ref_base<> error: invalid type (reference)"); static_assert(!std::is_reference_v<T>, "vm::_ref_base<> error: invalid type (reference)");
static_assert(!std::is_function<T>::value, "vm::_ref_base<> error: invalid type (function)"); static_assert(!std::is_function_v<T>, "vm::_ref_base<> error: invalid type (function)");
static_assert(!std::is_void<T>::value, "vm::_ref_base<> error: invalid type (void)"); static_assert(!std::is_void_v<T>, "vm::_ref_base<> error: invalid type (void)");
public: public:
using type = T; using type = T;

View File

@ -435,7 +435,7 @@ std::tuple<T, T, u32> upload_untouched(std::span<to_be_t<const T>> src, std::spa
{ {
return untouched_impl::upload_untouched(src, dst); return untouched_impl::upload_untouched(src, dst);
} }
else if constexpr (std::is_same<T, u16>::value) else if constexpr (std::is_same_v<T, u16>)
{ {
if (primitive_restart_index > 0xffff) if (primitive_restart_index > 0xffff)
{ {

View File

@ -224,7 +224,7 @@ struct copy_unmodified_block_swizzled
template<typename T, typename U> template<typename T, typename U>
static void copy_mipmap_level(std::span<T> dst, std::span<const U> src, u16 words_per_block, u16 width_in_block, u16 row_count, u16 depth, u8 border, u32 dst_pitch_in_block) static void copy_mipmap_level(std::span<T> dst, std::span<const U> 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<T, U>::value && dst_pitch_in_block == width_in_block && words_per_block == 1 && !border) if (std::is_same_v<T, U> && dst_pitch_in_block == width_in_block && words_per_block == 1 && !border)
{ {
rsx::convert_linear_swizzle_3d<T>(src.data(), dst.data(), width_in_block, row_count, depth); rsx::convert_linear_swizzle_3d<T>(src.data(), dst.data(), width_in_block, row_count, depth);
} }

View File

@ -1,5 +1,8 @@
#pragma once #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_utils.h"
#include "texture_cache_predictor.h" #include "texture_cache_predictor.h"
#include "texture_cache_helpers.h" #include "texture_cache_helpers.h"
@ -35,7 +38,7 @@ namespace rsx
using copy_region_descriptor = copy_region_descriptor_base<typename traits::image_resource_type>; using copy_region_descriptor = copy_region_descriptor_base<typename traits::image_resource_type>;
private: private:
static_assert(std::is_base_of<rsx::cached_texture_section<section_storage_type, traits>, section_storage_type>::value, "section_storage_type must derive from rsx::cached_texture_section"); static_assert(std::is_base_of_v<rsx::cached_texture_section<section_storage_type, traits>, section_storage_type>, "section_storage_type must derive from rsx::cached_texture_section");
/** /**
* Helper structs/enums * Helper structs/enums

View File

@ -3,6 +3,7 @@
#include <util/types.hpp> #include <util/types.hpp>
#include "Emu/Cell/lv2/sys_rsx.h" #include "Emu/Cell/lv2/sys_rsx.h"
#include "Emu/RSX/GCM.h" #include "Emu/RSX/GCM.h"
#include "Emu/RSX/rsx_utils.h"
#include "RSXIOMap.hpp" #include "RSXIOMap.hpp"
namespace rsx namespace rsx

View File

@ -157,7 +157,7 @@ namespace rsx
return; return;
} }
if constexpr (std::is_floating_point<T>::value) if constexpr (std::is_floating_point_v<T>)
{ {
m_value_label.set_text(fmt::format("%.2f%s", this->m_last_value, m_suffix)); m_value_label.set_text(fmt::format("%.2f%s", this->m_last_value, m_suffix));
} }

View File

@ -497,15 +497,15 @@ template<typename T> std::string FragmentProgramDecompiler::GetSRC(T src)
std::string ret; std::string ret;
u32 precision_modifier = 0; u32 precision_modifier = 0;
if constexpr (std::is_same<T, SRC0>::value) if constexpr (std::is_same_v<T, SRC0>)
{ {
precision_modifier = src1.src0_prec_mod; precision_modifier = src1.src0_prec_mod;
} }
else if constexpr (std::is_same<T, SRC1>::value) else if constexpr (std::is_same_v<T, SRC1>)
{ {
precision_modifier = src1.src1_prec_mod; precision_modifier = src1.src1_prec_mod;
} }
else if constexpr (std::is_same<T, SRC2>::value) else if constexpr (std::is_same_v<T, SRC2>)
{ {
precision_modifier = src1.src2_prec_mod; precision_modifier = src1.src2_prec_mod;
} }

View File

@ -288,11 +288,11 @@ public:
return set_error(elf_error::header_magic); return set_error(elf_error::header_magic);
// Check class // Check class
if (header.e_class != (std::is_same<sz_t, u32>::value ? 1 : 2)) if (header.e_class != (std::is_same_v<sz_t, u32> ? 1 : 2))
return set_error(elf_error::header_class); return set_error(elf_error::header_class);
// Check endianness // Check endianness
if (header.e_data != (std::is_same<en_t<u32>, le_t<u32>>::value ? 1 : 2)) if (header.e_data != (std::is_same_v<en_t<u32>, le_t<u32>> ? 1 : 2))
return set_error(elf_error::header_endianness); return set_error(elf_error::header_endianness);
// Check machine // Check machine
@ -413,8 +413,8 @@ public:
// Write header // Write header
ehdr_t header{}; ehdr_t header{};
header.e_magic = "\177ELF"_u32; header.e_magic = "\177ELF"_u32;
header.e_class = std::is_same<sz_t, u32>::value ? 1 : 2; header.e_class = std::is_same_v<sz_t, u32> ? 1 : 2;
header.e_data = std::is_same<en_t<u32>, le_t<u32>>::value ? 1 : 2; header.e_data = std::is_same_v<en_t<u32>, le_t<u32>> ? 1 : 2;
header.e_curver = 1; header.e_curver = 1;
header.e_os_abi = OS != elf_os::none ? OS : this->header.e_os_abi; header.e_os_abi = OS != elf_os::none ? OS : this->header.e_os_abi;
header.e_abi_ver = this->header.e_abi_ver; header.e_abi_ver = this->header.e_abi_ver;

View File

@ -889,7 +889,7 @@ T cheat_manager_dialog::convert_from_QString(const QString& str, bool& success)
{ {
T result; T result;
if constexpr (std::is_same<T, u8>::value) if constexpr (std::is_same_v<T, u8>)
{ {
const u16 result_16 = str.toUShort(&success); 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<T>(result_16); result = static_cast<T>(result_16);
} }
if constexpr (std::is_same<T, u16>::value) if constexpr (std::is_same_v<T, u16>)
result = str.toUShort(&success); result = str.toUShort(&success);
if constexpr (std::is_same<T, u32>::value) if constexpr (std::is_same_v<T, u32>)
result = str.toUInt(&success); result = str.toUInt(&success);
if constexpr (std::is_same<T, u64>::value) if constexpr (std::is_same_v<T, u64>)
result = str.toULongLong(&success); result = str.toULongLong(&success);
if constexpr (std::is_same<T, s8>::value) if constexpr (std::is_same_v<T, s8>)
{ {
const s16 result_16 = str.toShort(&success); const s16 result_16 = str.toShort(&success);
if (result_16 < -128 || result_16 > 127) 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<T>(result_16); result = static_cast<T>(result_16);
} }
if constexpr (std::is_same<T, s16>::value) if constexpr (std::is_same_v<T, s16>)
result = str.toShort(&success); result = str.toShort(&success);
if constexpr (std::is_same<T, s32>::value) if constexpr (std::is_same_v<T, s32>)
result = str.toInt(&success); result = str.toInt(&success);
if constexpr (std::is_same<T, s64>::value) if constexpr (std::is_same_v<T, s64>)
result = str.toLongLong(&success); result = str.toLongLong(&success);
return result; return result;

View File

@ -1338,7 +1338,7 @@ public:
auto fetch_add(const ptr_rt& rhs) auto fetch_add(const ptr_rt& rhs)
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::fetch_add(m_data, rhs); return atomic_storage<type>::fetch_add(m_data, rhs);
} }
@ -1351,7 +1351,7 @@ public:
auto add_fetch(const ptr_rt& rhs) auto add_fetch(const ptr_rt& rhs)
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::add_fetch(m_data, rhs); return atomic_storage<type>::add_fetch(m_data, rhs);
} }
@ -1365,7 +1365,7 @@ public:
auto operator +=(const ptr_rt& rhs) auto operator +=(const ptr_rt& rhs)
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::add_fetch(m_data, rhs); return atomic_storage<type>::add_fetch(m_data, rhs);
} }
@ -1378,7 +1378,7 @@ public:
auto fetch_sub(const ptr_rt& rhs) auto fetch_sub(const ptr_rt& rhs)
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::fetch_sub(m_data, rhs); return atomic_storage<type>::fetch_sub(m_data, rhs);
} }
@ -1391,7 +1391,7 @@ public:
auto sub_fetch(const ptr_rt& rhs) auto sub_fetch(const ptr_rt& rhs)
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::sub_fetch(m_data, rhs); return atomic_storage<type>::sub_fetch(m_data, rhs);
} }
@ -1405,7 +1405,7 @@ public:
auto operator -=(const ptr_rt& rhs) auto operator -=(const ptr_rt& rhs)
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::sub_fetch(m_data, rhs); return atomic_storage<type>::sub_fetch(m_data, rhs);
} }
@ -1418,7 +1418,7 @@ public:
auto fetch_and(const type& rhs) auto fetch_and(const type& rhs)
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::fetch_and(m_data, rhs); return atomic_storage<type>::fetch_and(m_data, rhs);
} }
@ -1431,7 +1431,7 @@ public:
auto and_fetch(const type& rhs) auto and_fetch(const type& rhs)
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::and_fetch(m_data, rhs); return atomic_storage<type>::and_fetch(m_data, rhs);
} }
@ -1445,7 +1445,7 @@ public:
auto operator &=(const type& rhs) auto operator &=(const type& rhs)
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::and_fetch(m_data, rhs); return atomic_storage<type>::and_fetch(m_data, rhs);
} }
@ -1458,7 +1458,7 @@ public:
auto fetch_or(const type& rhs) auto fetch_or(const type& rhs)
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::fetch_or(m_data, rhs); return atomic_storage<type>::fetch_or(m_data, rhs);
} }
@ -1471,7 +1471,7 @@ public:
auto or_fetch(const type& rhs) auto or_fetch(const type& rhs)
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::or_fetch(m_data, rhs); return atomic_storage<type>::or_fetch(m_data, rhs);
} }
@ -1485,7 +1485,7 @@ public:
auto operator |=(const type& rhs) auto operator |=(const type& rhs)
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::or_fetch(m_data, rhs); return atomic_storage<type>::or_fetch(m_data, rhs);
} }
@ -1498,7 +1498,7 @@ public:
auto fetch_xor(const type& rhs) auto fetch_xor(const type& rhs)
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::fetch_xor(m_data, rhs); return atomic_storage<type>::fetch_xor(m_data, rhs);
} }
@ -1511,7 +1511,7 @@ public:
auto xor_fetch(const type& rhs) auto xor_fetch(const type& rhs)
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::xor_fetch(m_data, rhs); return atomic_storage<type>::xor_fetch(m_data, rhs);
} }
@ -1525,7 +1525,7 @@ public:
auto operator ^=(const type& rhs) auto operator ^=(const type& rhs)
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::xor_fetch(m_data, rhs); return atomic_storage<type>::xor_fetch(m_data, rhs);
} }
@ -1538,7 +1538,7 @@ public:
auto operator ++() auto operator ++()
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::inc_fetch(m_data); return atomic_storage<type>::inc_fetch(m_data);
} }
@ -1551,7 +1551,7 @@ public:
auto operator --() auto operator --()
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::dec_fetch(m_data); return atomic_storage<type>::dec_fetch(m_data);
} }
@ -1564,7 +1564,7 @@ public:
auto operator ++(int) auto operator ++(int)
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::fetch_inc(m_data); return atomic_storage<type>::fetch_inc(m_data);
} }
@ -1577,7 +1577,7 @@ public:
auto operator --(int) auto operator --(int)
{ {
if constexpr(std::is_integral<type>::value) if constexpr(std::is_integral_v<type>)
{ {
return atomic_storage<type>::fetch_dec(m_data); return atomic_storage<type>::fetch_dec(m_data);
} }
@ -1636,7 +1636,7 @@ public:
bool bit_test_set(uint bit) bool bit_test_set(uint bit)
{ {
if constexpr (std::is_integral<type>::value) if constexpr (std::is_integral_v<type>)
{ {
return atomic_storage<type>::bts(m_data, bit & (sizeof(T) * 8 - 1)); return atomic_storage<type>::bts(m_data, bit & (sizeof(T) * 8 - 1));
} }
@ -1652,7 +1652,7 @@ public:
bool bit_test_reset(uint bit) bool bit_test_reset(uint bit)
{ {
if constexpr (std::is_integral<type>::value) if constexpr (std::is_integral_v<type>)
{ {
return atomic_storage<type>::btr(m_data, bit & (sizeof(T) * 8 - 1)); return atomic_storage<type>::btr(m_data, bit & (sizeof(T) * 8 - 1));
} }
@ -1668,7 +1668,7 @@ public:
bool bit_test_invert(uint bit) bool bit_test_invert(uint bit)
{ {
if constexpr (std::is_integral<type>::value) if constexpr (std::is_integral_v<type>)
{ {
return atomic_storage<type>::btc(m_data, bit & (sizeof(T) * 8 - 1)); return atomic_storage<type>::btc(m_data, bit & (sizeof(T) * 8 - 1));
} }

View File

@ -154,9 +154,9 @@ namespace stx
stype m_data; stype m_data;
static_assert(!std::is_pointer<type>::value, "se_t<> error: invalid type (pointer)"); static_assert(!std::is_pointer_v<type>, "se_t<> error: invalid type (pointer)");
static_assert(!std::is_reference<type>::value, "se_t<> error: invalid type (reference)"); static_assert(!std::is_reference_v<type>, "se_t<> error: invalid type (reference)");
static_assert(!std::is_array<type>::value, "se_t<> error: invalid type (array)"); static_assert(!std::is_array_v<type>, "se_t<> error: invalid type (array)");
static_assert(sizeof(type) == alignof(type), "se_t<> error: unexpected alignment"); static_assert(sizeof(type) == alignof(type), "se_t<> error: unexpected alignment");
static constexpr stype to_data(type value) noexcept static constexpr stype to_data(type value) noexcept

View File

@ -14,7 +14,7 @@ namespace rpcs3
return static_cast<usz>(value); return static_cast<usz>(value);
} }
template <typename T, typename = std::enable_if_t<std::is_integral<T>::value>> template <typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
static inline usz hash64(usz hash_value, T data) static inline usz hash64(usz hash_value, T data)
{ {
hash_value ^= data; hash_value ^= data;

View File

@ -16,7 +16,7 @@ struct to_se
}; };
template <typename T2> template <typename T2>
struct to_se_<T2, std::enable_if_t<std::is_arithmetic<T2>::value || std::is_enum<T2>::value>> struct to_se_<T2, std::enable_if_t<std::is_arithmetic_v<T2> || std::is_enum_v<T2>>>
{ {
using type = std::conditional_t<(sizeof(T2) > 1), se_t<T2, Se>, T2>; using type = std::conditional_t<(sizeof(T2) > 1), se_t<T2, Se>, T2>;
}; };
@ -44,14 +44,14 @@ struct to_se<s128, Se>
}; };
template <typename T, bool Se> template <typename T, bool Se>
struct to_se<const T, Se, std::enable_if_t<!std::is_array<T>::value>> struct to_se<const T, Se, std::enable_if_t<!std::is_array_v<T>>>
{ {
// Move const qualifier // Move const qualifier
using type = const typename to_se<T, Se>::type; using type = const typename to_se<T, Se>::type;
}; };
template <typename T, bool Se> template <typename T, bool Se>
struct to_se<volatile T, Se, std::enable_if_t<!std::is_array<T>::value && !std::is_const<T>::value>> struct to_se<volatile T, Se, std::enable_if_t<!std::is_array_v<T> && !std::is_const_v<T>>>
{ {
// Move volatile qualifier // Move volatile qualifier
using type = volatile typename to_se<T, Se>::type; using type = volatile typename to_se<T, Se>::type;

View File

@ -752,7 +752,7 @@ inline u32 offset32(T T2::*const mptr)
template <typename T> template <typename T>
struct offset32_array struct offset32_array
{ {
static_assert(std::is_array<T>::value, "Invalid pointer-to-member type (array expected)"); static_assert(std::is_array_v<T>, "Invalid pointer-to-member type (array expected)");
template <typename Arg> template <typename Arg>
static inline u32 index32(const Arg& arg) static inline u32 index32(const Arg& arg)
@ -956,7 +956,7 @@ template <typename From, typename To = void, typename = void>
struct narrow_impl struct narrow_impl
{ {
// Temporarily (diagnostic) // Temporarily (diagnostic)
static_assert(std::is_void<To>::value, "narrow_impl<> specialization not found"); static_assert(std::is_void_v<To>, "narrow_impl<> specialization not found");
// Returns true if value cannot be represented in type To // Returns true if value cannot be represented in type To
static constexpr bool test(const From&) static constexpr bool test(const From&)
@ -968,7 +968,7 @@ struct narrow_impl
// Unsigned to unsigned narrowing // Unsigned to unsigned narrowing
template <typename From, typename To> template <typename From, typename To>
struct narrow_impl<From, To, std::enable_if_t<std::is_unsigned<From>::value && std::is_unsigned<To>::value>> struct narrow_impl<From, To, std::enable_if_t<std::is_unsigned_v<From> && std::is_unsigned_v<To>>>
{ {
static constexpr bool test(const From& value) static constexpr bool test(const From& value)
{ {
@ -978,7 +978,7 @@ struct narrow_impl<From, To, std::enable_if_t<std::is_unsigned<From>::value && s
// Signed to signed narrowing // Signed to signed narrowing
template <typename From, typename To> template <typename From, typename To>
struct narrow_impl<From, To, std::enable_if_t<std::is_signed<From>::value && std::is_signed<To>::value>> struct narrow_impl<From, To, std::enable_if_t<std::is_signed_v<From> && std::is_signed_v<To>>>
{ {
static constexpr bool test(const From& value) static constexpr bool test(const From& value)
{ {
@ -988,7 +988,7 @@ struct narrow_impl<From, To, std::enable_if_t<std::is_signed<From>::value && std
// Unsigned to signed narrowing // Unsigned to signed narrowing
template <typename From, typename To> template <typename From, typename To>
struct narrow_impl<From, To, std::enable_if_t<std::is_unsigned<From>::value && std::is_signed<To>::value>> struct narrow_impl<From, To, std::enable_if_t<std::is_unsigned_v<From> && std::is_signed_v<To>>>
{ {
static constexpr bool test(const From& value) static constexpr bool test(const From& value)
{ {
@ -998,7 +998,7 @@ struct narrow_impl<From, To, std::enable_if_t<std::is_unsigned<From>::value && s
// Signed to unsigned narrowing (I) // Signed to unsigned narrowing (I)
template <typename From, typename To> template <typename From, typename To>
struct narrow_impl<From, To, std::enable_if_t<std::is_signed<From>::value && std::is_unsigned<To>::value && sizeof(To) >= sizeof(From)>> struct narrow_impl<From, To, std::enable_if_t<std::is_signed_v<From> && std::is_unsigned_v<To> && sizeof(To) >= sizeof(From)>>
{ {
static constexpr bool test(const From& value) static constexpr bool test(const From& value)
{ {
@ -1008,7 +1008,7 @@ struct narrow_impl<From, To, std::enable_if_t<std::is_signed<From>::value && std
// Signed to unsigned narrowing (II) // Signed to unsigned narrowing (II)
template <typename From, typename To> template <typename From, typename To>
struct narrow_impl<From, To, std::enable_if_t<std::is_signed<From>::value && std::is_unsigned<To>::value && sizeof(To) < sizeof(From)>> struct narrow_impl<From, To, std::enable_if_t<std::is_signed_v<From> && std::is_unsigned_v<To> && sizeof(To) < sizeof(From)>>
{ {
static constexpr bool test(const From& value) static constexpr bool test(const From& value)
{ {