MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / MaxInt

Function MaxInt

Bcore/src/main/cpp/base/bit_utils.h:304–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302// Generate maximum/minimum values for signed/unsigned n-bit integers
303template <typename T>
304constexpr T MaxInt(size_t bits) {
305 DCHECK(std::is_unsigned<T>::value || bits > 0u) << "bits cannot be zero for signed.";
306 DCHECK_LE(bits, BitSizeOf<T>());
307 using unsigned_type = typename std::make_unsigned<T>::type;
308 return bits == BitSizeOf<T>()
309 ? std::numeric_limits<T>::max()
310 : std::is_signed<T>::value
311 ? ((bits == 1u) ? 0 : static_cast<T>(MaxInt<unsigned_type>(bits - 1)))
312 : static_cast<T>(UINT64_C(1) << bits) - static_cast<T>(1);
313}
314
315template <typename T>
316constexpr T MinInt(size_t bits) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected