1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-05 15:55:45 +00:00

Rename HasMember to TupleHasType and move code into misc/meta.hpp

This commit is contained in:
ζeh Matt 2022-09-08 00:13:50 +03:00
parent 1f2c473242
commit 8f7703d5c8
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0
2 changed files with 21 additions and 9 deletions

View File

@ -6,6 +6,7 @@
#include <unordered_map>
#include <tuple>
#include <components/misc/meta.hpp>
#include <components/esm/luascripts.hpp>
#include <components/esm3/loadgmst.hpp>
@ -125,20 +126,12 @@ namespace MWWorld
// Special entry which is hardcoded and not loaded from an ESM
Store<ESM::Attribute >>;
template <class T, class Tuple>
struct HasMember;
template <class T, class ... Args>
struct HasMember<T, std::tuple<Store<Args> ...>> {
static constexpr bool value = (std::is_same_v<T, Args> || ...);
};
static std::size_t geNextTypeIndex();
template<typename T>
static std::size_t getTypeIndex()
{
static_assert(HasMember<T, StoreTuple>::value);
static_assert(Misc::TupleHasType<Store<T>, StoreTuple>::value);
static std::size_t sIndex = geNextTypeIndex();
return sIndex;
}

19
components/misc/meta.hpp Normal file
View File

@ -0,0 +1,19 @@
#ifndef OPENMW_COMPONENTS_MISC_META_H
#define OPENMW_COMPONENTS_MISC_META_H
#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> || ...);
};
}
#endif