1
boost::mpl::apply
元函数仅适用于模板类型参数。例如,下面的工作:boost :: mpl :: apply仅适用于键入的模板参数
using namespace boost::mpl;
template <class U, class S = int>
struct Bar { };
using BarInt = apply<Bar<_1>, int>::type;
但是,如果我有一个非类型参数单独的类模板:
template <class U, int S = 50>
struct Quux { };
using QuuxInt = apply<Quux<_1>, int>::type;
我得到一个编译错误,如:
/usr/include/boost/mpl/aux_/preprocessed/gcc/apply_wrap.hpp:36:8: error: no class template named ‘apply’ in ‘struct Quux<mpl_::arg<1> >’
struct apply_wrap1
^
foo.cxx: In function ‘int main()’:
foo.cxx:25:21: error: expected type-specifier
using QuuxInt = apply<Quux<_1>, int>::type;
^
有没有办法解决这个问题,除了为Bar创建一个子类型,使所有的非类型参数都变成类型参数?