I cannot imagine why it was chosen that std::bitset::size non-static. This greatly complicates the size of constexpr ; you should write something like this:
template<int val> struct int_ { static const constexpr value = val; }; template<size_t size> auto getBitsetSizeIMPL(std::bitset<size>) { return int_<size>{}; } template<typename BitsetType> constexpr size_t getBitsetSize() { return decltype(getBitsetSizeIMPL(BitsetType{}))::value; }
If it were static, all you would have to do would be
BitsetType::size()
and there will be no sacrifice of functionality.
Is there a historical reason why I am absent, or is there a technical fact that I am missing?
source share