Are there standard type types with dimensions that are template parameters?

Suppose I need to create a template with a member of length Nlength, where Nis the template parameter. I could, of course, define something like this

#include <cstdint>
template<int N>
struct sized_uint {};
template<> struct sized_uint<8> { typedef uint8_t type; };
template<> struct sized_uint<16> { typedef uint16_t type; };
template<> struct sized_uint<32> { typedef uint32_t type; };
template<> struct sized_uint<64> { typedef uint64_t type; };

and then use it in my template, for example. function:

template<int N> void myfunc(typename sized_uint<N>::type);

But are there any standard types like those described above sized_uintin any version of C ++?

+4
source share
1 answer

. , boost:: int_t, , , . , , boost::int_t , , , .

+7

Source: https://habr.com/ru/post/1598896/


All Articles