From 4bb9a4166dfc7797586c165672c71854523236c9 Mon Sep 17 00:00:00 2001 From: "florent.teppe" Date: Mon, 5 Sep 2022 18:38:59 +0200 Subject: [PATCH] The tuple types declaration is back in the header, but there is no need for implementation details to be known for any of the types --- apps/openmw/mwworld/esmstore.cpp | 49 +------------------------- apps/openmw/mwworld/esmstore.hpp | 59 ++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 48 deletions(-) diff --git a/apps/openmw/mwworld/esmstore.cpp b/apps/openmw/mwworld/esmstore.cpp index 615bfb7d6f..d4f1554564 100644 --- a/apps/openmw/mwworld/esmstore.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -135,54 +135,7 @@ namespace MWWorld struct ESMStoreImp { - std::tuple < - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - Store, - - // Lists that need special rules - Store, - Store, - Store, - Store, - - Store, - Store, - - // Special entry which is hardcoded and not loaded from an ESM - Store> mStores; + ESMStore::StoreTuple mStores; std::map mRecNameToStore; std::unordered_map mStoreToRecName; diff --git a/apps/openmw/mwworld/esmstore.hpp b/apps/openmw/mwworld/esmstore.hpp index 30e77ffce0..3890dcaa51 100644 --- a/apps/openmw/mwworld/esmstore.hpp +++ b/apps/openmw/mwworld/esmstore.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -33,11 +34,69 @@ namespace MWWorld { friend struct ESMStoreImp; //This allows StoreImp to extend esmstore without beeing included everywhere + using StoreTuple = std::tuple < + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + Store, + + // Lists that need special rules + Store, + Store, + Store, + Store, + + Store, + Store, + + // Special entry which is hardcoded and not loaded from an ESM + Store>; + + template + struct HasMember; + + template + struct HasMember ...>> { + static constexpr bool value = (std::is_same_v || ...); + }; + static std::size_t &getTypeIndexCounter(); template static std::size_t getTypeIndex() { + static_assert(HasMember::value); static std::size_t sIndex = getTypeIndexCounter()++; return sIndex; }