From 29ad4ecc78a1da7fcfc61a7303f4cb9aaaec6d47 Mon Sep 17 00:00:00 2001 From: oltolm Date: Tue, 25 Feb 2025 18:43:07 +0100 Subject: [PATCH] concepts: fix review notes --- Utilities/File.h | 5 +++++ Utilities/StrFmt.h | 10 +++++----- rpcs3/Emu/Cell/Modules/cellSail.h | 1 + rpcs3/Emu/Memory/vm_ptr.h | 12 ++++++------ rpcs3/util/fixed_typemap.hpp | 4 ++-- rpcs3/util/serialization.hpp | 10 ++++------ 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Utilities/File.h b/Utilities/File.h index f3adaa15d4..828a0384b6 100644 --- a/Utilities/File.h +++ b/Utilities/File.h @@ -1,5 +1,6 @@ #pragma once // No BOM and only basic ASCII in this header, or a neko will die +#include "util/serialization.hpp" #include "util/types.hpp" #include "util/shared_ptr.hpp" #include "bit_set.h" @@ -78,6 +79,8 @@ namespace fs constexpr bool operator==(const stat_t&) const = default; }; + static_assert(utils::Bitcopy); + // Helper, layout is equal to iovec struct struct iovec_clone { @@ -126,6 +129,8 @@ namespace fs using enable_bitcopy = std::false_type; }; + static_assert(!utils::Bitcopy); + // Directory handle base struct dir_base { diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index 0f1d0fb604..05d98fdfab 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -130,7 +130,7 @@ struct fmt_unveil> }; // String type format provider, also type classifier (format() called if an argument is formatted as "%s") -template +template struct fmt_class_string { // Formatting function (must be explicitly specialized) @@ -215,7 +215,7 @@ struct fmt_class_string : fmt_class_string }; template <> -struct fmt_class_string +struct fmt_class_string { static void format(std::string& out, u64 arg); }; @@ -237,7 +237,7 @@ struct fmt_class_string : fmt_class_string }; template <> -struct fmt_class_string +struct fmt_class_string { static void format(std::string& out, u64 arg); }; @@ -257,7 +257,7 @@ namespace fmt } template -struct fmt_class_string +struct fmt_class_string { static FORCE_INLINE SAFE_BUFFERS(const T&) get_object(u64 arg) { @@ -278,7 +278,7 @@ namespace fmt } template -struct fmt_class_string +struct fmt_class_string { static FORCE_INLINE SAFE_BUFFERS(const T&) get_object(u64 arg) { diff --git a/rpcs3/Emu/Cell/Modules/cellSail.h b/rpcs3/Emu/Cell/Modules/cellSail.h index c8b9716ada..91e66dc5f0 100644 --- a/rpcs3/Emu/Cell/Modules/cellSail.h +++ b/rpcs3/Emu/Cell/Modules/cellSail.h @@ -1,5 +1,6 @@ #pragma once +#include "Emu/Memory/vm_ptr.h" #include "cellVpost.h" // Error Codes diff --git a/rpcs3/Emu/Memory/vm_ptr.h b/rpcs3/Emu/Memory/vm_ptr.h index 28accf7316..5081e0701d 100644 --- a/rpcs3/Emu/Memory/vm_ptr.h +++ b/rpcs3/Emu/Memory/vm_ptr.h @@ -441,37 +441,37 @@ struct fmt_unveil> }; template <> -struct fmt_class_string, void> +struct fmt_class_string> { static void format(std::string& out, u64 arg); }; template -struct fmt_class_string, void> : fmt_class_string, void> +struct fmt_class_string> : fmt_class_string> { // Classify all pointers as const void* }; template <> -struct fmt_class_string, void> +struct fmt_class_string> { static void format(std::string& out, u64 arg); }; template <> -struct fmt_class_string, void> : fmt_class_string> +struct fmt_class_string> : fmt_class_string> { // Classify char* as const char* }; template -struct fmt_class_string, void> : fmt_class_string> +struct fmt_class_string> : fmt_class_string> { // Classify const char[] as const char* }; template -struct fmt_class_string, void> : fmt_class_string> +struct fmt_class_string> : fmt_class_string> { // Classify char[] as const char* }; diff --git a/rpcs3/util/fixed_typemap.hpp b/rpcs3/util/fixed_typemap.hpp index 2e95a06689..65d161c333 100644 --- a/rpcs3/util/fixed_typemap.hpp +++ b/rpcs3/util/fixed_typemap.hpp @@ -144,7 +144,7 @@ namespace stx } template - requires requires(T& a, utils::serial& ar) { a.save(ar); } + requires requires(T& a, utils::serial& ar) { a.save(stx::exact_t(ar)); } static void call_save(void* ptr, utils::serial& ar) noexcept { std::launder(static_cast(ptr))->save(stx::exact_t(ar)); @@ -170,7 +170,7 @@ namespace stx r.thread_op = &call_thread_op; } - if constexpr (!!(requires(T& a, utils::serial& ar) { a.save(ar); })) + if constexpr (!!(requires(T& a, utils::serial& ar) { a.save(stx::exact_t(ar)); })) { r.save = &call_save; } diff --git a/rpcs3/util/serialization.hpp b/rpcs3/util/serialization.hpp index 730c81c24c..866fd7c0f4 100644 --- a/rpcs3/util/serialization.hpp +++ b/rpcs3/util/serialization.hpp @@ -18,9 +18,7 @@ namespace utils }; template - concept Bitcopy = (std::is_arithmetic_v) || (std::is_enum_v) || Integral || requires() { - typename T::enable_bitcopy; - }; + concept Bitcopy = (std::is_arithmetic_v) || (std::is_enum_v) || Integral || typename T::enable_bitcopy()(); template concept TupleAlike = (!FastRandomAccess) && requires () @@ -29,8 +27,8 @@ namespace utils }; template - concept ListAlike = requires(std::remove_cvref_t& obj, T::value_type item) { obj.insert(obj.end(), item); }; + concept ListAlike = requires(std::remove_cvref_t& obj, T::value_type item) { obj.insert(obj.end(), std::move(item)); }; struct serial; struct serialization_file_handler @@ -123,7 +121,7 @@ public: m_expect_little_data = value; } - // Return true if small amounts of both input and output memory are expected (performance hint) + // Return true if small amounts of both input and output memory are expected (performance hint) bool expect_little_data() const { return m_expect_little_data; @@ -427,7 +425,7 @@ public: } template - requires requires(T& obj, utils::serial& ar) { (obj.*(&T::operator()))(ar); } + requires requires(T& obj, utils::serial& ar) { (obj.*(&T::operator()))(stx::exact_t(ar)); } bool serialize(T& obj) { obj(*this);