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:
parent
1f2c473242
commit
8f7703d5c8
@ -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
19
components/misc/meta.hpp
Normal 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
|
Loading…
Reference in New Issue
Block a user