Why std :: bitset :: size is non-static

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?

+6
source share
1 answer

The assumption of non constexpr std::bitset::size is wrong:

 std::size_t size() const; // until C++11 constexpr std::size_t size(); // since C++11, until C++14 constexpr std::size_t size() const; // since C++14) 
+1
source

All Articles