是否可以使用模板类指针声明模板函数?像这样:
template <typename FirstType, typename ... TypesRemaining>
class MyClass
{
// ...
};
template <int n, template <typename FirstType, typename ... TypesRemaining> typename MyClass<FirstType, TypesRemaining...>::*ptr> myFunction() {
// ...
}
是否可以使用&#39;使用&#39;声明指针类型?像这样:
template <typename FirstType, typename ... TypesRemaining>
class MyClass
{
// ...
};
template<typename FirstType, typename ... TypesRemaining>
using ptrMyClass = MyClass<FirstType, TypesRemaining...>*;
template <int n, template <typename FirstType, typename ... TypesRemaining> typename ptrMyClass<FirstType, TypesRemaining...> ptr> myFunction() {
// ...
}
答案 0 :(得分:1)
你可以做这样的事情(用clang编译好,用gcc给ICE):
float totalHours = 0;
foreach(Person p in peopleList){
totalHours += p.workedHours;
}