是否可以创建一个宏来减少模板结构定义的样板,而模板结构只显示其所有模板参数?
template <
typename TPar1,
int TPar2,
...
bool TParN
>
struct MyStruct {
using Par1 = TPar1;
static int const Par2 = TPar2;
...
static bool const ParN = TParN;
};
请注意模板参数类型的不规则映射( typename
- > using
, TYPE
- > static TYPE const
) . 我也会对某种无法自动映射这些类型的解决方案感到满意,但是例如只支持typename或者需要提示它是类型名还是类型 .
1 回答
我找到了解决方案 . 一些功劳归于this answer,用于计算传递的参数数量 .
此示例扩展为: