Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the following functions in `src/util.hpp`: template<typename T> inline std::size_t bit_width(); template<typename T> inline std::size_t bit_width(T x); These functions compute the size, in bits, of a type or value, providing a convenient and self-documenting name for the underlying expression, `sizeof(…) * std::numeric_limits<unsigned char>::digits`. This commit adds two additional header `#include` directives in `src/util.hpp`. The newly included headers are as follows: - `<cstddef>`, for `std::size_t`; and - `<limits>`, for `std::numeric_limits`. At first, I obtained the bit width of a byte using the C preprocessor macro `CHAR_BIT`, defined in the C standard library header `<climits>`, rather than using `std::numeric_limits<unsigned char>::digits`, but I subsequently switched to using `std::numeric_limits` per Soliton’s recommendation at 2014-03-17 21:36Z in the `#wesnoth-dev` IRC channel on the freenode IRC network (<irc://chat.freenode.net/%23wesnoth-dev>).
- Loading branch information