Common: Create Range Projections For std::pair

This commit is contained in:
mitaclaw 2024-09-29 14:07:27 -07:00
parent b8921b1338
commit d77e0c665c
3 changed files with 32 additions and 0 deletions

View File

@ -113,6 +113,7 @@ add_library(common
PcapFile.h PcapFile.h
Profiler.cpp Profiler.cpp
Profiler.h Profiler.h
Projection.h
QoSSession.cpp QoSSession.cpp
QoSSession.h QoSSession.h
Random.cpp Random.cpp

View File

@ -0,0 +1,30 @@
// Copyright 2025 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <utility>
namespace Common::Projection
{
struct First
{
// TODO C++23: static operator()
template <class T>
[[nodiscard]] constexpr auto&& operator()(T&& t) const noexcept
{
return std::forward<T>(t).first;
}
};
struct Second
{
// TODO C++23: static operator()
template <class T>
[[nodiscard]] constexpr auto&& operator()(T&& t) const noexcept
{
return std::forward<T>(t).second;
}
};
using Key = First;
using Value = Second;
} // namespace Common::Projection

View File

@ -143,6 +143,7 @@
<ClInclude Include="Common\Network.h" /> <ClInclude Include="Common\Network.h" />
<ClInclude Include="Common\PcapFile.h" /> <ClInclude Include="Common\PcapFile.h" />
<ClInclude Include="Common\Profiler.h" /> <ClInclude Include="Common\Profiler.h" />
<ClInclude Include="Common\Projection.h" />
<ClInclude Include="Common\QoSSession.h" /> <ClInclude Include="Common\QoSSession.h" />
<ClInclude Include="Common\Random.h" /> <ClInclude Include="Common\Random.h" />
<ClInclude Include="Common\Result.h" /> <ClInclude Include="Common\Result.h" />