Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Cafe/GameProfile/GameProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ bool gameProfile_loadIntegerOption(IniParser* iniParser, const char* optionName,
template <typename T>
bool gameProfile_loadIntegerOption(IniParser& iniParser, const char* optionName, T& option, T minVal, T maxVal)
{
static_assert(std::is_integral<T>::value);
static_assert(std::is_integral_v<T>);
auto option_value = iniParser.FindOption(optionName);
if (!option_value)
return false;
Expand All @@ -133,7 +133,7 @@ bool gameProfile_loadIntegerOption(IniParser& iniParser, const char* optionName,
template<typename T>
bool gameProfile_loadEnumOption(IniParser& iniParser, const char* optionName, T& option)
{
static_assert(std::is_enum<T>::value);
static_assert(std::is_enum_v<T>);
auto option_value = iniParser.FindOption(optionName);
if (!option_value)
return false;
Expand Down Expand Up @@ -366,4 +366,4 @@ void GameProfile::Reset()
// controller settings
for (auto& profile : m_controllerProfile)
profile.reset();
}
}
2 changes: 1 addition & 1 deletion src/Cafe/HW/Latte/Core/LatteBufferCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TNodeObject>::value == false, "TNodeObject must be a non-pointer type");
static_assert(!std::is_pointer_v<TNodeObject>, "TNodeObject must be a non-pointer type");

struct InternalRange
{
Expand Down
8 changes: 4 additions & 4 deletions src/Cafe/OS/common/OSUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,14 @@ void cafeExportCallWrapper(PPCInterpreter_t* hCPU)
if(cemuLog_advancedPPCLoggingEnabled())
{
MPTR threadMPTR = memory_getVirtualOffsetFromPointer(coreinit::OSGetCurrentThread());
if constexpr (std::tuple_size<decltype(format_tup)>::value > 0)
if constexpr (std::tuple_size_v<decltype(format_tup)> > 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<decltype(format_tup)>::value > 0)
if constexpr (std::tuple_size_v<decltype(format_tup)> > 0)
{
shouldLog = cemuLog_log(TLogType, "{}.{}{}", TNames::GetLib(), TNames::GetFunc(), format_tup);
}
Expand All @@ -192,7 +192,7 @@ void cafeExportCallWrapper(PPCInterpreter_t* hCPU)
}
}

if constexpr (!std::is_void<decltype(std::apply(fn, tup))>::value)
if constexpr (!std::is_void_v<decltype(std::apply(fn, tup))>)
{
// has non-void return type
decltype(auto) result = std::apply(fn, tup);
Expand Down Expand Up @@ -241,4 +241,4 @@ MPTR makeCallableExport()
return PPCInterpreter_makeCallableExportDepr(&cafeExportCallWrapper<fn, "CALLABLE_EXPORT">);
}

void osLib_addVirtualPointer(const char* libraryName, const char* functionName, uint32 vPtr);
void osLib_addVirtualPointer(const char* libraryName, const char* functionName, uint32 vPtr);
14 changes: 7 additions & 7 deletions src/Cafe/OS/libs/gx2/GX2_Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ inline void gx2WriteGather_submit_(uint32 coreIndex, uint32be* writePtr, const b
}

template <typename T, typename ...Targs>
requires std::is_floating_point_v<T>
inline
typename std::enable_if< std::is_floating_point<T>::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;
Expand All @@ -50,9 +50,9 @@ gx2WriteGather_submit_(uint32 coreIndex, uint32be* writePtr, const T& arg, Targs
}

template <typename T, typename ...Targs>
requires std::is_base_of_v<Latte::LATTEREG, T>
inline
typename std::enable_if< std::is_base_of<Latte::LATTEREG, T>::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();
Expand All @@ -61,9 +61,9 @@ gx2WriteGather_submit_(uint32 coreIndex, uint32be* writePtr, const T& arg, Targs
}

template <typename T, typename ...Targs>
requires (!std::is_base_of_v<Latte::LATTEREG, T>) && (!std::is_floating_point_v<T>)
inline
typename std::enable_if< !std::is_base_of<Latte::LATTEREG, T>::value && !std::is_floating_point<T>::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++;
Expand Down Expand Up @@ -105,4 +105,4 @@ namespace GX2
void GX2Init_commandBufferPool(void* bufferBase, uint32 bufferSize);
void GX2Shutdown_commandBufferPool();
void GX2CommandResetToDefaultState();
}
}
2 changes: 1 addition & 1 deletion src/Cemu/ExpressionParser/ExpressionParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TExpressionParser
template<typename T>
T Evaluate(std::string_view expression) const
{
static_assert(std::is_arithmetic<T>::value, "type T must be an arithmetic type");
static_assert(std::is_arithmetic_v<T>, "type T must be an arithmetic type");
return (T)Evaluate(expression);
}

Expand Down
9 changes: 4 additions & 5 deletions src/Common/SysAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ class SysAllocator : public SysAllocatorBase
operator void*() { return m_sysMem->GetPtr(); }

// for all arrays except bool
template<class Q = T>
typename std::enable_if< count != 1 && !std::is_same<Q, bool>::value, Q >::type&
operator[](int index)
T& operator[](int index)
requires(count != 1) && (!std::is_same_v<T, bool>)
{
// return tmp data until we allocated in sys mem
if (m_sysMem.GetMPTR() == 0)
Expand All @@ -125,7 +124,7 @@ class SysAllocator : public SysAllocatorBase

return m_sysMem[index];
}
private:
private:
SysAllocator(uint32 memptr)
: m_sysMem(memptr)
{}
Expand Down Expand Up @@ -215,4 +214,4 @@ class SysAllocator<T, 1> : public SysAllocatorBase

MEMPTR<T> m_sysMem;
T m_tempData;
};
};
10 changes: 5 additions & 5 deletions src/Common/betype.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ constexpr T bswap(T i)
template <typename T>
constexpr T SwapEndian(T value)
{
if constexpr (std::is_integral<T>::value)
if constexpr (std::is_integral_v<T>)
{
#ifdef _MSC_VER
if constexpr (sizeof(T) == sizeof(uint32_t))
Expand All @@ -33,7 +33,7 @@ constexpr T SwapEndian(T value)

return (T)bswap((std::make_unsigned_t<T>)value);
}
else if constexpr (std::is_floating_point<T>::value)
else if constexpr (std::is_floating_point_v<T>)
{
if constexpr (sizeof(T) == sizeof(uint32_t))
{
Expand All @@ -46,18 +46,18 @@ constexpr T SwapEndian(T value)
return *(T*)&tmp;
}
}
else if constexpr (std::is_enum<T>::value)
else if constexpr (std::is_enum_v<T>)
{
return (T)SwapEndian((std::underlying_type_t<T>)value);
}
else if constexpr (std::is_base_of<Latte::LATTEREG, T>::value)
else if constexpr (std::is_base_of_v<Latte::LATTEREG, T>)
{
const auto tmp = bswap<uint32_t>(*(uint32_t*)&value);
return *(T*)&tmp;
}
else
{
static_assert(std::is_integral<T>::value, "unsupported betype specialization!");
static_assert(std::is_integral_v<T>, "unsupported betype specialization!");
}

return value;
Expand Down
60 changes: 31 additions & 29 deletions src/Common/enumFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,63 +10,65 @@ struct EnableBitMaskOperators
};

template<typename TEnum>
typename std::enable_if<EnableBitMaskOperators<TEnum>::enable, TEnum>::type
operator &(TEnum lhs, TEnum rhs)
requires EnableBitMaskOperators<TEnum>::enable
TEnum operator &(TEnum lhs, TEnum rhs)
{
return static_cast<TEnum> (static_cast<typename std::underlying_type<TEnum>::type>(lhs) & static_cast<typename std::underlying_type<TEnum>::type>(rhs));
}

template<typename TEnum>
typename std::enable_if<EnableBitMaskOperators<TEnum>::enable, TEnum>::type
operator |(TEnum lhs, TEnum rhs)
requires EnableBitMaskOperators<TEnum>::enable
TEnum operator |(TEnum lhs, TEnum rhs)
{
return static_cast<TEnum> (static_cast<typename std::underlying_type<TEnum>::type>(lhs) | static_cast<typename std::underlying_type<TEnum>::type>(rhs));
}

template<typename TEnum>
typename std::enable_if<EnableBitMaskOperators<TEnum>::enable, TEnum>::type
operator ^(TEnum lhs, TEnum rhs)
requires EnableBitMaskOperators<TEnum>::enable
TEnum operator ^(TEnum lhs, TEnum rhs)
{
return static_cast<TEnum> (static_cast<typename std::underlying_type<TEnum>::type>(lhs) ^ static_cast<typename std::underlying_type<TEnum>::type>(rhs));
}

template<typename TEnum>
typename std::enable_if<EnableBitMaskOperators<TEnum>::enable, TEnum>::type
operator ~(TEnum rhs)
requires EnableBitMaskOperators<TEnum>::enable
TEnum operator ~(TEnum rhs)
{
return static_cast<TEnum> (~static_cast<typename std::underlying_type<TEnum>::type>(rhs));
}

template<typename TEnum>
typename std::enable_if<EnableBitMaskOperators<TEnum>::enable, TEnum>::type&
operator &=(TEnum& lhs, TEnum rhs)
requires EnableBitMaskOperators<TEnum>::enable
TEnum& operator &=(TEnum& lhs, TEnum rhs)
{
lhs = static_cast<TEnum> (static_cast<typename std::underlying_type<TEnum>::type>(lhs) & static_cast<typename std::underlying_type<TEnum>::type>(rhs));
return lhs;
}

template<typename TEnum>
typename std::enable_if<EnableBitMaskOperators<TEnum>::enable, TEnum>::type&
operator |=(TEnum& lhs, TEnum rhs)
requires EnableBitMaskOperators<TEnum>::enable
TEnum& operator |=(TEnum& lhs, TEnum rhs)
{
lhs = static_cast<TEnum> (static_cast<typename std::underlying_type<TEnum>::type>(lhs) | static_cast<typename std::underlying_type<TEnum>::type>(rhs));
return lhs;
}

template<typename TEnum>
typename std::enable_if<EnableBitMaskOperators<TEnum>::enable, TEnum>::type&
operator ^=(TEnum& lhs, TEnum rhs)
requires EnableBitMaskOperators<TEnum>::enable
TEnum& operator ^=(TEnum& lhs, TEnum rhs)
{
lhs = static_cast<TEnum> (static_cast<typename std::underlying_type<TEnum>::type>(lhs) ^ static_cast<typename std::underlying_type<TEnum>::type>(rhs));
return lhs;
}

template<typename TEnum, typename = std::enable_if_t<EnableBitMaskOperators<TEnum>::enable>>
template<typename TEnum>
requires EnableBitMaskOperators<TEnum>::enable
constexpr bool operator==(TEnum lhs, std::underlying_type_t<TEnum> rhs)
{
return static_cast<std::underlying_type_t<TEnum>>(lhs) == rhs;
}
template<typename TEnum, typename = std::enable_if_t<EnableBitMaskOperators<TEnum>::enable>>
template<typename TEnum>
requires EnableBitMaskOperators<TEnum>::enable
constexpr bool operator!=(TEnum lhs, std::underlying_type_t<TEnum> rhs)
{
return static_cast<std::underlying_type_t<TEnum>>(lhs) != rhs;
Expand All @@ -82,43 +84,43 @@ struct EnableEnumIterators
};

template<typename TEnum>
typename std::enable_if<EnableEnumIterators<TEnum>::enable, TEnum>::type&
operator++(TEnum& lhs)
requires EnableEnumIterators<TEnum>::enable
TEnum& operator++(TEnum& lhs)
{
lhs = static_cast<TEnum>(static_cast<typename std::underlying_type<TEnum>::type>(lhs) + 1);
return lhs;
}

template<typename TEnum>
typename std::enable_if<EnableEnumIterators<TEnum>::enable, TEnum>::type
operator*(TEnum rhs)
requires EnableEnumIterators<TEnum>::enable
TEnum operator*(TEnum rhs)
{
return rhs;
}

template<typename TEnum>
typename std::enable_if<EnableEnumIterators<TEnum>::enable, TEnum>::type
begin(TEnum value)
requires EnableEnumIterators<TEnum>::enable
TEnum begin(TEnum value)
{
return EnableEnumIterators<TEnum>::begin;
}

template<typename TEnum>
typename std::enable_if<EnableEnumIterators<TEnum>::enable, TEnum>::type
rbegin(TEnum value)
requires EnableEnumIterators<TEnum>::enable
TEnum rbegin(TEnum value)
{
return EnableEnumIterators<TEnum>::rbegin;
}

template<typename TEnum>
typename std::enable_if<EnableEnumIterators<TEnum>::enable, TEnum>::type
end(TEnum r) {
requires EnableEnumIterators<TEnum>::enable
TEnum end(TEnum r) {
return EnableEnumIterators<TEnum>::end;
}

template<typename TEnum>
typename std::enable_if<EnableEnumIterators<TEnum>::enable, TEnum>::type
rend(TEnum r) {
requires EnableEnumIterators<TEnum>::enable
TEnum rend(TEnum r) {
return EnableEnumIterators<TEnum>::rend;
}

Expand All @@ -129,4 +131,4 @@ rend(TEnum r) {
static const x end = static_cast<x>(static_cast<typename std::underlying_type<x>::type>(last_value) + 1);\
static const x rend = static_cast<x>(static_cast<typename std::underlying_type<x>::type>(first_value) - 1);\
};
// todo: rend type must be signed?
// todo: rend type must be signed?
5 changes: 3 additions & 2 deletions src/Common/precompiled.h
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,8 @@ struct fmt::formatter<betype<T>> : fmt::formatter<T>
namespace stdx
{
// std::to_underlying
template <typename EnumT, typename = std::enable_if_t < std::is_enum<EnumT>{} >>
template <typename EnumT>
requires (std::is_enum_v<EnumT>)
constexpr std::underlying_type_t<EnumT> to_underlying(EnumT e) noexcept {
return static_cast<std::underlying_type_t<EnumT>>(e);
};
Expand Down Expand Up @@ -689,7 +690,7 @@ namespace stdx
template<typename T>
class atomic_ref
{
static_assert(std::is_trivially_copyable<T>::value, "atomic_ref requires trivially copyable types");
static_assert(std::is_trivially_copyable_v<T>, "atomic_ref requires trivially copyable types");
public:
using value_type = T;

Expand Down
12 changes: 6 additions & 6 deletions src/config/ConfigValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ class ConfigValueNoneAtomic
m_value = v;
}

template <typename = typename std::enable_if<std::is_same_v<TType, std::string>>>
void SetValue(std::string_view v)
requires std::is_same_v<TType, std::string>
{
std::lock_guard lock(m_mutex);
m_value = v;
}

template <typename = typename std::enable_if<std::is_same_v<TType, std::wstring>>>
void SetValue(std::wstring_view v)
requires std::is_same_v<TType, std::string>
{
std::lock_guard lock(m_mutex);
m_value = v;
Expand Down Expand Up @@ -171,22 +171,22 @@ class ConfigValueBounds : public ConfigValue<TType>
}

// init from enum with iterators
template<typename TEnum = typename std::enable_if<std::is_enum<TType>::value && EnableEnumIterators<TType>::enable, TType>>
constexpr ConfigValueBounds()
: base_type(), m_min_value(begin(TEnum{})), m_max_value(rbegin(TEnum{}))
requires std::is_enum_v<TType> && EnableEnumIterators<TType>::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<typename TEnum = typename std::enable_if<std::is_enum<TType>::value && EnableEnumIterators<TType>::enable, TType>>
constexpr ConfigValueBounds(const TType& init_value)
requires std::is_enum_v<TType> && EnableEnumIterators<TType>::enable
: base_type(std::forward<TType>(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<typename TEnum = typename std::enable_if<std::is_enum<TType>::value && EnableEnumIterators<TType>::enable, TType>>
constexpr ConfigValueBounds(TType&& init_value)
requires std::is_enum_v<TType> && EnableEnumIterators<TType>::enable
: base_type(std::forward<TType>(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);
Expand Down
Loading
Loading