i have specific situation in prepare runtime structures @ compile time without need duplicate code. i have 2 structs use register @ compile time types compiler wrote: using typeid = u8; template<typename t, typename type_id, type_id i> struct typehelper { static constexpr type_id value = std::integral_constant<type_id, i>::value; }; template<typename t> struct type : typehelper<t, u8, __counter__> { static_assert(!std::is_same<t,t>::value, "must specialize type!"); }; these used in config header macro specialize type<t> multiple types require: using type_size = unsigned char; #define get_nth_macro(_1,_2,_3, name,...) name #define register_type(...) get_nth_macro(__va_args__, register_type3, register_type2, register_type1)(__va_args__) #define register_type1(_type_) register_type2(_type_, _type_) #define register_type2(_type_,_name_) \ constexpr typeid type_##_name_ = __counter__; \ template<> struct type<_type_...
Comments
Post a Comment