Нет такой черты типа в стандарте, но вы можете сделать что-то похожее самостоятельно:
#include <cstdint>
#include <limits>
#include <type_traits>
template <auto capacity, typename... intTypes>
struct intRequiredImpl;
template <auto capacity, typename intType>
struct intRequiredImpl<capacity, intType> {
using type = intType;
// avoid overflow
static_assert(capacity <= std::numeric_limits<type>::max(),
"Largest specified type is not capable of holding the capacity.");
};
template <auto capacity, typename SmallInt, typename... LargeInts>
struct intRequiredImpl <capacity, SmallInt, LargeInts...> {
using type = std::conditional_t <
(capacity <= std::numeric_limits<SmallInt>::max()),
SmallInt, typename intRequiredImpl<capacity, LargeInts...>::type>;
};
template <auto capacity>
using uintRequired = typename intRequiredImpl<capacity,
std::uint8_t,
std::uint16_t,
std::uint32_t,
std::uint64_t>::type;
int main() {
uintRequired<50> i; // std::uint8_t
}