From 1e5e9219cd122761911bb426750af72c750c7efd Mon Sep 17 00:00:00 2001 From: mitaclaw <140017135+mitaclaw@users.noreply.github.com> Date: Sun, 29 Sep 2024 14:07:27 -0700 Subject: [PATCH] Common: Create Range Projections For `std::pair` --- Source/Core/Common/CMakeLists.txt | 1 + Source/Core/Common/Projection.h | 30 ++++++++++++++++++++++++++++++ Source/Core/DolphinLib.props | 1 + 3 files changed, 32 insertions(+) create mode 100644 Source/Core/Common/Projection.h diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt index 8f3eeb0a27..c368cde1d6 100644 --- a/Source/Core/Common/CMakeLists.txt +++ b/Source/Core/Common/CMakeLists.txt @@ -114,6 +114,7 @@ add_library(common PcapFile.h Profiler.cpp Profiler.h + Projection.h QoSSession.cpp QoSSession.h Random.cpp diff --git a/Source/Core/Common/Projection.h b/Source/Core/Common/Projection.h new file mode 100644 index 0000000000..d571508134 --- /dev/null +++ b/Source/Core/Common/Projection.h @@ -0,0 +1,30 @@ +// Copyright 2025 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include + +namespace Common::Projection +{ +struct First +{ + // TODO C++23: static operator() + template + [[nodiscard]] constexpr auto&& operator()(T&& t) const noexcept + { + return std::forward(t).first; + } +}; + +struct Second +{ + // TODO C++23: static operator() + template + [[nodiscard]] constexpr auto&& operator()(T&& t) const noexcept + { + return std::forward(t).second; + } +}; + +using Key = First; +using Value = Second; +} // namespace Common::Projection diff --git a/Source/Core/DolphinLib.props b/Source/Core/DolphinLib.props index 367c347213..61cf4eddaa 100644 --- a/Source/Core/DolphinLib.props +++ b/Source/Core/DolphinLib.props @@ -144,6 +144,7 @@ +