2022-09-07 21:13:50 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_MISC_META_H
|
|
|
|
#define OPENMW_COMPONENTS_MISC_META_H
|
|
|
|
|
2022-09-07 21:31:29 +00:00
|
|
|
#include <cstddef>
|
2022-09-07 21:13:50 +00:00
|
|
|
#include <tuple>
|
|
|
|
#include <type_traits>
|
|
|
|
|
|
|
|
namespace Misc
|
|
|
|
{
|
|
|
|
template <class T, class Tuple>
|
|
|
|
struct TupleHasType;
|
|
|
|
|
|
|
|
template <class T, class... Args>
|
|
|
|
struct TupleHasType<T, std::tuple<Args...>>
|
|
|
|
{
|
|
|
|
static constexpr bool value = (std::is_same_v<T, Args> || ...);
|
|
|
|
};
|
2022-09-07 21:31:29 +00:00
|
|
|
|
|
|
|
template <class T, class Tuple>
|
|
|
|
struct TupleTypeIndex;
|
|
|
|
|
|
|
|
template <class T, class... Types>
|
|
|
|
struct TupleTypeIndex<T, std::tuple<T, Types...>>
|
|
|
|
{
|
|
|
|
static constexpr std::size_t value = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class T, class U, class... Types>
|
|
|
|
struct TupleTypeIndex<T, std::tuple<U, Types...>>
|
|
|
|
{
|
|
|
|
static constexpr std::size_t value = 1 + TupleTypeIndex<T, std::tuple<Types...>>::value;
|
|
|
|
};
|
2022-09-07 21:13:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|