jjzjj

Automagically

全部标签

C++14 元编程 : Automagically build a list of types at compile/init time

使用C++14和CuriouslyRecurringTemplatePattern(CRTP)以及可能的Boost.Hana的某种组合(或boost::mpl如果您愿意),我可以在编译时(或静态初始化时)构建一个类型列表而无需显式声明吗?例如,我有这样的东西(在Coliru上查看):#include#include#includenamespace{structD1{staticconstexprautoval=10;};structD2{staticconstexprautoval=20;};structD3{staticconstexprautoval=30;};}intmain(