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

crashfix_debugdraw
ζeh Matt 2 years ago
parent 1f2c473242
commit 8f7703d5c8
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0

@ -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;
}

@ -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
Loading…
Cancel
Save