I wish to write a template structure foo
such that foo<N>::value_type
is the nearest sized integer (rounding up) to N
. For example foo<32>::value_type => uint32_t
, foo<33>::value_type => uint64_t
and foo<72>::value_type => uint64_t
.
To do this I need an elegant means of providing partial specializations of foo
for a range of values, e.g, 1 <= N <= 8
to return uint8_t and so on and so fourth. Is there a means of accomplishing this without having to specialise everything from 0 to 64.