enable_if
要激活这样的调度:
typedef boost::mpl::vector<std::int16_t, std::int32_t, int64_t, float, double, std::complex<float>, std::complex<double> > Types;
template <typename Vector>
typename boost::enable_if<typename boost::mpl::empty<Vector>::type, void>::type void process(/*args*/)
{
}
template <typename Vector>
typename boost::disable_if<typename boost::mpl::empty<Vector>::type, void>::type void process(/*args*/)
{
process<typename boost::mpl::pop_front<Vector>::type>();
}
void outside()
{
process<Types>();
}
因此,用C++ 17,我可以使用CONTXPR,但我仍然是我必须通过的类型列表。
outside
. 有没有合适的方法来声明容器类型以便我可以使用可变模板?