// This work derives from Vittorio Romeo's code used for cppcon 2015 licensed under the Academic Free License. // His code is available here: https://github.com/SuperV1234/cppcon2015 #ifndef EC_BITSET_HPP #define EC_BITSET_HPP #include #include "Meta/TypeList.hpp" #include "Meta/Combine.hpp" #include "Meta/IndexOf.hpp" #include "Meta/ForEach.hpp" namespace EC { template struct Bitset : public std::bitset { using Combined = EC::Meta::Combine; template constexpr auto getComponentBit() const { return (*this)[EC::Meta::IndexOf::value]; } template constexpr auto getComponentBit() { return (*this)[EC::Meta::IndexOf::value]; } template constexpr auto getTagBit() const { return (*this)[EC::Meta::IndexOf::value]; } template constexpr auto getTagBit() { return (*this)[EC::Meta::IndexOf::value]; } template static constexpr Bitset generateBitset() { Bitset bitset; EC::Meta::forEach([&bitset] (auto t) { if(EC::Meta::Contains::value) { bitset[EC::Meta::IndexOf::value] = true; } }); return bitset; } }; } #endif