code golf

a place to keep my worst crimes

who needs stdint.h anyway

#define val static constexpr
	namespace unsigned_integrals {
		#define entry(i,_u,_s) template <> struct entry<i>{using u=_u;using s = _s;}
		template <unsigned char index> struct entry { using s = void; using u = void; };
		entry(0, unsigned char,       signed char);
		entry(1, unsigned short,      signed short);
		entry(2, unsigned int,        signed int);
		entry(3, unsigned long,       signed long);
		entry(4, unsigned long long,  signed long long);
		entry(5, __uint128_t, __int128_t);
		#undef entry
	
		template <size_t bits, size_t i> struct select {
			val size_t v = (
				sizeof(typename entry<i>::u)*8 >= bits
					? i
					: select<bits,i+1>::v
			);
		};
		template <size_t bits> struct select<bits, 6> { val size_t v = 6; };
	}

	template <size_t bits> struct ints {
		using u = typename unsigned_integrals::entry<unsigned_integrals::select<bits,0>::v>::u;
		using s = typename unsigned_integrals::entry<unsigned_integrals::select<bits,0>::v>::s;
	
	};
	int main() {
		using uint16 = ints<16>::u; // unsigned short
	}