65,210
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
template<typename type_t>
struct ParamType {
typedef type_t& type;
};
template<>
struct ParamType<int> {
typedef int type;
};
template<typename t>
void print(typename ParamType<t>::type i)
{
cout<<i<<endl;
}
int main()
{
int i = 10;
print(i);
return 0;
}
G:\Projects\ParamTest\main.cpp|29|error: no matching function for call to `print(int&)'|
既然已经特化了,就特殊对待呗.
print<int>(i);