mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-25 23:37:57 +00:00
Common: Add variant utilities
This commit is contained in:
parent
cb576bf382
commit
2dce7e6e21
@ -159,6 +159,7 @@
|
|||||||
<ClInclude Include="TraversalClient.h" />
|
<ClInclude Include="TraversalClient.h" />
|
||||||
<ClInclude Include="TraversalProto.h" />
|
<ClInclude Include="TraversalProto.h" />
|
||||||
<ClInclude Include="UPnP.h" />
|
<ClInclude Include="UPnP.h" />
|
||||||
|
<ClInclude Include="VariantUtil.h" />
|
||||||
<ClInclude Include="Version.h" />
|
<ClInclude Include="Version.h" />
|
||||||
<ClInclude Include="WorkQueueThread.h" />
|
<ClInclude Include="WorkQueueThread.h" />
|
||||||
<ClInclude Include="x64ABI.h" />
|
<ClInclude Include="x64ABI.h" />
|
||||||
|
26
Source/Core/Common/VariantUtil.h
Normal file
26
Source/Core/Common/VariantUtil.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright 2018 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2+
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
template <typename... From>
|
||||||
|
struct VariantCastProxy
|
||||||
|
{
|
||||||
|
const std::variant<From...>& v;
|
||||||
|
|
||||||
|
template <typename... To>
|
||||||
|
operator std::variant<To...>() const
|
||||||
|
{
|
||||||
|
return std::visit([](auto&& arg) { return std::variant<To...>{arg}; }, v);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
template <typename... From>
|
||||||
|
auto VariantCast(const std::variant<From...>& v)
|
||||||
|
{
|
||||||
|
return detail::VariantCastProxy<From...>{v};
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user