Added utilty header for variant stuff (Visitor type and variant_contains_v).
This commit is contained in:
parent
def91ac1bf
commit
acb5d5b04e
@ -12,18 +12,10 @@
|
|||||||
|
|
||||||
#include "../container/optional.hpp"
|
#include "../container/optional.hpp"
|
||||||
#include "../util/traits.hpp"
|
#include "../util/traits.hpp"
|
||||||
|
#include "../util/variant.hpp"
|
||||||
|
|
||||||
namespace mijin
|
namespace mijin
|
||||||
{
|
{
|
||||||
//
|
|
||||||
// public traits
|
|
||||||
//
|
|
||||||
|
|
||||||
template<typename TSearch, typename TVariant>
|
|
||||||
inline constexpr bool variant_contains_v = false;
|
|
||||||
|
|
||||||
template<typename TSearch, typename... TVariantTypes>
|
|
||||||
inline constexpr bool variant_contains_v<TSearch, std::variant<TVariantTypes...>> = mijin::is_any_type_v<TSearch, TVariantTypes...>;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// public types
|
// public types
|
||||||
|
29
source/mijin/util/variant.hpp
Normal file
29
source/mijin/util/variant.hpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if !defined(MIJIN_UTIL_VARIANT_HPP_INCLUDED)
|
||||||
|
#define MIJIN_UTIL_VARIANT_HPP_INCLUDED 1
|
||||||
|
|
||||||
|
namespace mijin
|
||||||
|
{
|
||||||
|
|
||||||
|
//
|
||||||
|
// public traits
|
||||||
|
//
|
||||||
|
|
||||||
|
template<typename TSearch, typename TVariant>
|
||||||
|
inline constexpr bool variant_contains_v = false;
|
||||||
|
|
||||||
|
template<typename TSearch, typename... TVariantTypes>
|
||||||
|
inline constexpr bool variant_contains_v<TSearch, std::variant<TVariantTypes...>> = mijin::is_any_type_v<TSearch, TVariantTypes...>;
|
||||||
|
|
||||||
|
//
|
||||||
|
// public types
|
||||||
|
//
|
||||||
|
template<typename... TCallable>
|
||||||
|
struct Visitor : TCallable ...
|
||||||
|
{
|
||||||
|
using TCallable::operator()...;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif // !defined(MIJIN_UTIL_VARIANT_HPP_INCLUDED)
|
Loading…
x
Reference in New Issue
Block a user