To do this, you need to make your own template specialization:
template<typename tp> class bigger { } template class bigger<boost::int8_t> { typedef boost::int16_t type; } template class bigger<boost::int16_t> { typedef boost::int32_t type; } template class bigger<boost::int32_t> { typedef boost::int64_t type; }
You can also make a macro if you don't like typing a lot:
#define BIGGER(x, y) \ template \ class bigger<boost::int##x##_t> \ { \ typedef boost::int##y##_t type; \ } BIGGER(8, 16); BIGGER(16, 32); BIGGER(32, 64);
and then use it like
bigger<boost::int32_t>::type x;
source share