diff --git a/src/Cafe/GameProfile/GameProfile.cpp b/src/Cafe/GameProfile/GameProfile.cpp index ea303226..286f3411 100644 --- a/src/Cafe/GameProfile/GameProfile.cpp +++ b/src/Cafe/GameProfile/GameProfile.cpp @@ -106,7 +106,7 @@ bool gameProfile_loadIntegerOption(IniParser* iniParser, const char* optionName, template bool gameProfile_loadIntegerOption(IniParser& iniParser, const char* optionName, T& option, T minVal, T maxVal) { - static_assert(std::is_integral::value); + static_assert(std::is_integral_v); auto option_value = iniParser.FindOption(optionName); if (!option_value) return false; @@ -133,7 +133,7 @@ bool gameProfile_loadIntegerOption(IniParser& iniParser, const char* optionName, template bool gameProfile_loadEnumOption(IniParser& iniParser, const char* optionName, T& option) { - static_assert(std::is_enum::value); + static_assert(std::is_enum_v); auto option_value = iniParser.FindOption(optionName); if (!option_value) return false; @@ -366,4 +366,4 @@ void GameProfile::Reset() // controller settings for (auto& profile : m_controllerProfile) profile.reset(); -} \ No newline at end of file +} diff --git a/src/Cafe/HW/Latte/Core/LatteBufferCache.cpp b/src/Cafe/HW/Latte/Core/LatteBufferCache.cpp index 716312a3..0395771e 100644 --- a/src/Cafe/HW/Latte/Core/LatteBufferCache.cpp +++ b/src/Cafe/HW/Latte/Core/LatteBufferCache.cpp @@ -25,7 +25,7 @@ class IntervalTree2 // static TNodeObject* Split(TNodeObject* nodeObject, TRangeData firstRangeBegin, TRangeData firstRangeEnd, TRangeData secondRangeBegin, TRangeData secondRangeEnd) // Cut a hole into an existing range and split it in two. Should return the newly created node object after the hole - static_assert(std::is_pointer::value == false, "TNodeObject must be a non-pointer type"); + static_assert(!std::is_pointer_v, "TNodeObject must be a non-pointer type"); struct InternalRange { diff --git a/src/Cafe/OS/common/OSUtil.h b/src/Cafe/OS/common/OSUtil.h index 84e38a6c..31784882 100644 --- a/src/Cafe/OS/common/OSUtil.h +++ b/src/Cafe/OS/common/OSUtil.h @@ -176,14 +176,14 @@ void cafeExportCallWrapper(PPCInterpreter_t* hCPU) if(cemuLog_advancedPPCLoggingEnabled()) { MPTR threadMPTR = memory_getVirtualOffsetFromPointer(coreinit::OSGetCurrentThread()); - if constexpr (std::tuple_size::value > 0) + if constexpr (std::tuple_size_v > 0) shouldLog = cemuLog_log(TLogType, "{}.{}{} # LR: {:#x} | Thread: {:#x}", TNames::GetLib(), TNames::GetFunc(), format_tup, hCPU->spr.LR, threadMPTR); else shouldLog = cemuLog_log(TLogType, "{}.{}() # LR: {:#x} | Thread: {:#x}", TNames::GetLib(), TNames::GetFunc(), hCPU->spr.LR, threadMPTR); } else { - if constexpr (std::tuple_size::value > 0) + if constexpr (std::tuple_size_v > 0) { shouldLog = cemuLog_log(TLogType, "{}.{}{}", TNames::GetLib(), TNames::GetFunc(), format_tup); } @@ -192,7 +192,7 @@ void cafeExportCallWrapper(PPCInterpreter_t* hCPU) } } - if constexpr (!std::is_void::value) + if constexpr (!std::is_void_v) { // has non-void return type decltype(auto) result = std::apply(fn, tup); @@ -241,4 +241,4 @@ MPTR makeCallableExport() return PPCInterpreter_makeCallableExportDepr(&cafeExportCallWrapper); } -void osLib_addVirtualPointer(const char* libraryName, const char* functionName, uint32 vPtr); \ No newline at end of file +void osLib_addVirtualPointer(const char* libraryName, const char* functionName, uint32 vPtr); diff --git a/src/Cafe/OS/libs/gx2/GX2_Command.h b/src/Cafe/OS/libs/gx2/GX2_Command.h index 00f5d427..a27b2a02 100644 --- a/src/Cafe/OS/libs/gx2/GX2_Command.h +++ b/src/Cafe/OS/libs/gx2/GX2_Command.h @@ -39,9 +39,9 @@ inline void gx2WriteGather_submit_(uint32 coreIndex, uint32be* writePtr, const b } template + requires std::is_floating_point_v inline -typename std::enable_if< std::is_floating_point::value, void>::type -gx2WriteGather_submit_(uint32 coreIndex, uint32be* writePtr, const T& arg, Targs... args) +void gx2WriteGather_submit_(uint32 coreIndex, uint32be* writePtr, const T& arg, Targs... args) { static_assert(sizeof(T) == sizeof(uint32)); *writePtr = *(uint32*)&arg; @@ -50,9 +50,9 @@ gx2WriteGather_submit_(uint32 coreIndex, uint32be* writePtr, const T& arg, Targs } template + requires std::is_base_of_v inline -typename std::enable_if< std::is_base_of::value, void>::type -gx2WriteGather_submit_(uint32 coreIndex, uint32be* writePtr, const T& arg, Targs... args) +void gx2WriteGather_submit_(uint32 coreIndex, uint32be* writePtr, const T& arg, Targs... args) { static_assert(sizeof(Latte::LATTEREG) == sizeof(uint32be)); *writePtr = arg.getRawValue(); @@ -61,9 +61,9 @@ gx2WriteGather_submit_(uint32 coreIndex, uint32be* writePtr, const T& arg, Targs } template + requires (!std::is_base_of_v) && (!std::is_floating_point_v) inline -typename std::enable_if< !std::is_base_of::value && !std::is_floating_point::value, void>::type -gx2WriteGather_submit_(uint32 coreIndex, uint32be* writePtr, const T& arg, Targs... args) +void gx2WriteGather_submit_(uint32 coreIndex, uint32be* writePtr, const T& arg, Targs... args) { *writePtr = arg; writePtr++; @@ -105,4 +105,4 @@ namespace GX2 void GX2Init_commandBufferPool(void* bufferBase, uint32 bufferSize); void GX2Shutdown_commandBufferPool(); void GX2CommandResetToDefaultState(); -} \ No newline at end of file +} diff --git a/src/Cemu/ExpressionParser/ExpressionParser.h b/src/Cemu/ExpressionParser/ExpressionParser.h index ab14dc5d..e8ad6ce2 100644 --- a/src/Cemu/ExpressionParser/ExpressionParser.h +++ b/src/Cemu/ExpressionParser/ExpressionParser.h @@ -37,7 +37,7 @@ public: template T Evaluate(std::string_view expression) const { - static_assert(std::is_arithmetic::value, "type T must be an arithmetic type"); + static_assert(std::is_arithmetic_v, "type T must be an arithmetic type"); return (T)Evaluate(expression); } diff --git a/src/Common/SysAllocator.h b/src/Common/SysAllocator.h index 7a11601e..80afc129 100644 --- a/src/Common/SysAllocator.h +++ b/src/Common/SysAllocator.h @@ -113,9 +113,8 @@ public: operator void*() { return m_sysMem->GetPtr(); } // for all arrays except bool - template - typename std::enable_if< count != 1 && !std::is_same::value, Q >::type& - operator[](int index) + T& operator[](int index) + requires(count != 1) && (!std::is_same_v) { // return tmp data until we allocated in sys mem if (m_sysMem.GetMPTR() == 0) @@ -125,7 +124,7 @@ public: return m_sysMem[index]; } -private: + private: SysAllocator(uint32 memptr) : m_sysMem(memptr) {} @@ -215,4 +214,4 @@ private: MEMPTR m_sysMem; T m_tempData; -}; \ No newline at end of file +}; diff --git a/src/Common/betype.h b/src/Common/betype.h index 60a64b7a..501ee980 100644 --- a/src/Common/betype.h +++ b/src/Common/betype.h @@ -22,7 +22,7 @@ constexpr T bswap(T i) template constexpr T SwapEndian(T value) { - if constexpr (std::is_integral::value) + if constexpr (std::is_integral_v) { #ifdef _MSC_VER if constexpr (sizeof(T) == sizeof(uint32_t)) @@ -33,7 +33,7 @@ constexpr T SwapEndian(T value) return (T)bswap((std::make_unsigned_t)value); } - else if constexpr (std::is_floating_point::value) + else if constexpr (std::is_floating_point_v) { if constexpr (sizeof(T) == sizeof(uint32_t)) { @@ -46,18 +46,18 @@ constexpr T SwapEndian(T value) return *(T*)&tmp; } } - else if constexpr (std::is_enum::value) + else if constexpr (std::is_enum_v) { return (T)SwapEndian((std::underlying_type_t)value); } - else if constexpr (std::is_base_of::value) + else if constexpr (std::is_base_of_v) { const auto tmp = bswap(*(uint32_t*)&value); return *(T*)&tmp; } else { - static_assert(std::is_integral::value, "unsupported betype specialization!"); + static_assert(std::is_integral_v, "unsupported betype specialization!"); } return value; diff --git a/src/Common/enumFlags.h b/src/Common/enumFlags.h index ac63f4c6..a247b8e2 100644 --- a/src/Common/enumFlags.h +++ b/src/Common/enumFlags.h @@ -10,63 +10,65 @@ struct EnableBitMaskOperators }; template -typename std::enable_if::enable, TEnum>::type -operator &(TEnum lhs, TEnum rhs) + requires EnableBitMaskOperators::enable +TEnum operator &(TEnum lhs, TEnum rhs) { return static_cast (static_cast::type>(lhs) & static_cast::type>(rhs)); } template -typename std::enable_if::enable, TEnum>::type -operator |(TEnum lhs, TEnum rhs) + requires EnableBitMaskOperators::enable +TEnum operator |(TEnum lhs, TEnum rhs) { return static_cast (static_cast::type>(lhs) | static_cast::type>(rhs)); } template -typename std::enable_if::enable, TEnum>::type -operator ^(TEnum lhs, TEnum rhs) + requires EnableBitMaskOperators::enable +TEnum operator ^(TEnum lhs, TEnum rhs) { return static_cast (static_cast::type>(lhs) ^ static_cast::type>(rhs)); } template -typename std::enable_if::enable, TEnum>::type -operator ~(TEnum rhs) + requires EnableBitMaskOperators::enable +TEnum operator ~(TEnum rhs) { return static_cast (~static_cast::type>(rhs)); } template -typename std::enable_if::enable, TEnum>::type& -operator &=(TEnum& lhs, TEnum rhs) + requires EnableBitMaskOperators::enable +TEnum& operator &=(TEnum& lhs, TEnum rhs) { lhs = static_cast (static_cast::type>(lhs) & static_cast::type>(rhs)); return lhs; } template -typename std::enable_if::enable, TEnum>::type& -operator |=(TEnum& lhs, TEnum rhs) + requires EnableBitMaskOperators::enable +TEnum& operator |=(TEnum& lhs, TEnum rhs) { lhs = static_cast (static_cast::type>(lhs) | static_cast::type>(rhs)); return lhs; } template -typename std::enable_if::enable, TEnum>::type& -operator ^=(TEnum& lhs, TEnum rhs) + requires EnableBitMaskOperators::enable +TEnum& operator ^=(TEnum& lhs, TEnum rhs) { lhs = static_cast (static_cast::type>(lhs) ^ static_cast::type>(rhs)); return lhs; } -template::enable>> +template + requires EnableBitMaskOperators::enable constexpr bool operator==(TEnum lhs, std::underlying_type_t rhs) { return static_cast>(lhs) == rhs; } -template::enable>> +template + requires EnableBitMaskOperators::enable constexpr bool operator!=(TEnum lhs, std::underlying_type_t rhs) { return static_cast>(lhs) != rhs; @@ -82,43 +84,43 @@ struct EnableEnumIterators }; template -typename std::enable_if::enable, TEnum>::type& -operator++(TEnum& lhs) + requires EnableEnumIterators::enable +TEnum& operator++(TEnum& lhs) { lhs = static_cast(static_cast::type>(lhs) + 1); return lhs; } template -typename std::enable_if::enable, TEnum>::type -operator*(TEnum rhs) + requires EnableEnumIterators::enable +TEnum operator*(TEnum rhs) { return rhs; } template -typename std::enable_if::enable, TEnum>::type -begin(TEnum value) + requires EnableEnumIterators::enable +TEnum begin(TEnum value) { return EnableEnumIterators::begin; } template -typename std::enable_if::enable, TEnum>::type -rbegin(TEnum value) + requires EnableEnumIterators::enable +TEnum rbegin(TEnum value) { return EnableEnumIterators::rbegin; } template -typename std::enable_if::enable, TEnum>::type -end(TEnum r) { + requires EnableEnumIterators::enable +TEnum end(TEnum r) { return EnableEnumIterators::end; } template -typename std::enable_if::enable, TEnum>::type -rend(TEnum r) { + requires EnableEnumIterators::enable +TEnum rend(TEnum r) { return EnableEnumIterators::rend; } @@ -129,4 +131,4 @@ rend(TEnum r) { static const x end = static_cast(static_cast::type>(last_value) + 1);\ static const x rend = static_cast(static_cast::type>(first_value) - 1);\ }; -// todo: rend type must be signed? \ No newline at end of file +// todo: rend type must be signed? diff --git a/src/Common/precompiled.h b/src/Common/precompiled.h index 0c080f29..f48bba47 100644 --- a/src/Common/precompiled.h +++ b/src/Common/precompiled.h @@ -653,7 +653,8 @@ struct fmt::formatter> : fmt::formatter namespace stdx { // std::to_underlying - template {} >> + template + requires (std::is_enum_v) constexpr std::underlying_type_t to_underlying(EnumT e) noexcept { return static_cast>(e); }; @@ -689,7 +690,7 @@ namespace stdx template class atomic_ref { - static_assert(std::is_trivially_copyable::value, "atomic_ref requires trivially copyable types"); + static_assert(std::is_trivially_copyable_v, "atomic_ref requires trivially copyable types"); public: using value_type = T; diff --git a/src/config/ConfigValue.h b/src/config/ConfigValue.h index 43e2ad3b..ecffc119 100644 --- a/src/config/ConfigValue.h +++ b/src/config/ConfigValue.h @@ -96,15 +96,15 @@ public: m_value = v; } - template >> void SetValue(std::string_view v) + requires std::is_same_v { std::lock_guard lock(m_mutex); m_value = v; } - template >> void SetValue(std::wstring_view v) + requires std::is_same_v { std::lock_guard lock(m_mutex); m_value = v; @@ -171,22 +171,22 @@ public: } // init from enum with iterators - template::value && EnableEnumIterators::enable, TType>> constexpr ConfigValueBounds() - : base_type(), m_min_value(begin(TEnum{})), m_max_value(rbegin(TEnum{})) + requires std::is_enum_v && EnableEnumIterators::enable + : base_type(), m_min_value(begin(TType{})), m_max_value(rbegin(TType{})) { assert(m_min_value <= this->GetInitValue() && this->GetInitValue() <= m_max_value); } - template::value && EnableEnumIterators::enable, TType>> constexpr ConfigValueBounds(const TType& init_value) + requires std::is_enum_v && EnableEnumIterators::enable : base_type(std::forward(init_value)), m_min_value(begin(init_value)), m_max_value(rbegin(init_value)) { assert(m_min_value <= init_value && init_value <= m_max_value); } - template::value && EnableEnumIterators::enable, TType>> constexpr ConfigValueBounds(TType&& init_value) + requires std::is_enum_v && EnableEnumIterators::enable : base_type(std::forward(init_value)), m_min_value(begin(init_value)), m_max_value(rbegin(init_value)) { assert(m_min_value <= init_value && init_value <= m_max_value); diff --git a/src/config/XMLConfig.h b/src/config/XMLConfig.h index ea9cca82..049bc394 100644 --- a/src/config/XMLConfig.h +++ b/src/config/XMLConfig.h @@ -221,7 +221,7 @@ public: { auto* element = m_document->NewElement(name); - if constexpr (std::is_enum::value) + if constexpr (std::is_enum_v) element->SetText(fmt::format("{}", static_cast::type>(value)).c_str()); else element->SetText(fmt::format("{}", value).c_str()); diff --git a/src/gui/wxgui/helpers/wxControlObject.h b/src/gui/wxgui/helpers/wxControlObject.h index 45cafa44..5726001f 100644 --- a/src/gui/wxgui/helpers/wxControlObject.h +++ b/src/gui/wxgui/helpers/wxControlObject.h @@ -11,7 +11,7 @@ public: template T* GetControl() const { - static_assert(std::is_base_of::value, "T must inherit from wxControl"); + static_assert(std::is_base_of_v, "T must inherit from wxControl"); return dynamic_cast(m_control); } @@ -30,7 +30,7 @@ public: template T* GetControl(int index) const { - static_assert(std::is_base_of::value, "T must inherit from wxControl"); + static_assert(std::is_base_of_v, "T must inherit from wxControl"); if (index < 0 || index >= m_controls.size()) return nullptr; @@ -41,4 +41,4 @@ public: private: std::vector m_controls; -}; \ No newline at end of file +}; diff --git a/src/util/helpers/ringbuffer.h b/src/util/helpers/ringbuffer.h index aab77fc3..d58aca0f 100644 --- a/src/util/helpers/ringbuffer.h +++ b/src/util/helpers/ringbuffer.h @@ -10,9 +10,8 @@ public: bool Push(const T& v); - template - typename std::enable_if< !std::is_array::value, Q >::type - Pop() + T Pop() + requires (!std::is_array_v) { std::unique_lock lock(m_mutex); if (m_readPointer == m_writePointer)