Added utility type to convert variant members via std::visit.
This commit is contained in:
parent
042e0d2465
commit
79f49829d3
@ -4,6 +4,7 @@
|
||||
#if !defined(MIJIN_UTIL_VARIANT_HPP_INCLUDED)
|
||||
#define MIJIN_UTIL_VARIANT_HPP_INCLUDED 1
|
||||
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
#include "./traits.hpp"
|
||||
|
||||
@ -23,10 +24,21 @@ inline constexpr bool variant_contains_v<TSearch, std::variant<TVariantTypes...>
|
||||
//
|
||||
// public types
|
||||
//
|
||||
|
||||
template<typename... TCallable>
|
||||
struct Visitor : TCallable ...
|
||||
{
|
||||
using TCallable::operator()...;
|
||||
};
|
||||
|
||||
template<typename TRet>
|
||||
struct CastTo
|
||||
{
|
||||
template<typename T>
|
||||
TRet operator()(T&& arg) const
|
||||
{
|
||||
return static_cast<TRet>(std::forward<T>(arg));
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif // !defined(MIJIN_UTIL_VARIANT_HPP_INCLUDED)
|
||||
|
Loading…
x
Reference in New Issue
Block a user