From 45a2008aa6c7c43da6182cb3d6c96b7ab86902ac Mon Sep 17 00:00:00 2001 From: lizzie Date: Fri, 7 Nov 2025 17:03:01 +0100 Subject: [common] replace Common::(DerivedFrom, IsArithmetic, Size, ConvertibleTo, IsIntegral) with libstdc++ equivalents (#290) Signed-off-by: lizzie Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/290 Reviewed-by: crueter Reviewed-by: Caio Oliveira Co-authored-by: lizzie Co-committed-by: lizzie --- src/common/concepts.h | 23 +++-------------------- src/common/fixed_point.h | 15 +++++++++++---- 2 files changed, 14 insertions(+), 24 deletions(-) (limited to 'src/common') diff --git a/src/common/concepts.h b/src/common/concepts.h index 61df1d32a2..4c07443bac 100644 --- a/src/common/concepts.h +++ b/src/common/concepts.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -12,24 +15,4 @@ namespace Common { template concept IsContiguousContainer = std::contiguous_iterator; -// TODO: Replace with std::derived_from when the header -// is available on all supported platforms. -template -concept DerivedFrom = requires { - std::is_base_of_v; - std::is_convertible_v; - }; - -// TODO: Replace with std::convertible_to when libc++ implements it. -template -concept ConvertibleTo = std::is_convertible_v; - -// No equivalents in the stdlib - -template -concept IsArithmetic = std::is_arithmetic_v; - -template -concept IsIntegral = std::is_integral_v; - } // namespace Common diff --git a/src/common/fixed_point.h b/src/common/fixed_point.h index b0f3ae2ccb..c52c870812 100644 --- a/src/common/fixed_point.h +++ b/src/common/fixed_point.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: 2015 Evan Teran // SPDX-License-Identifier: MIT @@ -16,6 +19,10 @@ namespace Common { +// No equivalent for "std::arithmetic" in the stdlib +template +concept IsArithmetic = std::is_arithmetic_v; + template class FixedPoint; @@ -392,13 +399,13 @@ public: // binary math operators, effects underlying bit pattern since these return *this; } - template + template constexpr FixedPoint& operator>>=(Integer n) { data_ >>= n; return *this; } - template + template constexpr FixedPoint& operator<<=(Integer n) { data_ <<= n; return *this; @@ -587,12 +594,12 @@ constexpr FixedPoint operator/(Number lhs, FixedPoint rhs) { } // shift operators -template +template constexpr FixedPoint operator<<(FixedPoint lhs, Integer rhs) { lhs <<= rhs; return lhs; } -template +template constexpr FixedPoint operator>>(FixedPoint lhs, Integer rhs) { lhs >>= rhs; return lhs; -- cgit v1.2.3