| 29 | // Like sizeof, but count how many bits a type takes. Pass type explicitly. |
| 30 | template <typename T> |
| 31 | constexpr size_t BitSizeOf() { |
| 32 | static_assert(std::is_integral<T>::value, "T must be integral"); |
| 33 | using unsigned_type = typename std::make_unsigned<T>::type; |
| 34 | static_assert(sizeof(T) == sizeof(unsigned_type), "Unexpected type size mismatch!"); |
| 35 | static_assert(std::numeric_limits<unsigned_type>::radix == 2, "Unexpected radix!"); |
| 36 | return std::numeric_limits<unsigned_type>::digits; |
| 37 | } |
| 38 | |
| 39 | // Like sizeof, but count how many bits a type takes. Infers type from parameter. |
| 40 | template <typename T> |
no outgoing calls
no test coverage detected