曼 谷 我在不使用模板参数作为功能参数的情况下使用词汇模板?
在我使用时,它汇编了:
#include <iostream>
using namespace std;
template<class First>
void print(First first)
{
cout << 1 << endl;
}
template<class First, class ... Rest>
void print(First first, Rest ...rest)
{
cout << 1 << endl;
print<Rest...>(rest...);
}
int main()
{
print<int,int,int>(1,2,3);
}
但是,当我不使用它们时,它没有汇编和抱怨含糊不清:
#include <iostream>
using namespace std;
template<class First>
void print()
{
cout << 1 << endl;
}
template<class First, class ... Rest>
void print()
{
cout << 1 << endl;
print<Rest...>();
}
int main()
{
print<int,int,int>();
}
Unfortunately the classes I want to give as template parameters are not instantiable (they have static functions that are called inside of the template function). Is there a way to do this?