【发布时间】:2013-06-28 17:00:36
【问题描述】:
更多的模板问题...我喜欢 C++,但有时我讨厌它。
我不知道为什么编译器会在这里抱怨,以及我能做些什么。
struct blah
{
template<class t>
blah(void(*)(t), t){}
};
void Func(int i) {}
void Func2(int& i) {}
void test()
{
int i = 3;
blah b(Func, i);
blah b2(Func2, i); //error C2660: 'blah::blah' : function does not take 2 arguments
blah b3(Func2, (int&)i); //error C2660: 'blah::blah' : function does not take 2 arguments
}
这是怎么回事?
我正在使用 MSVC2008。
【问题讨论】:
-
(int&)i与i相同(两者都没有引用类型)
标签: c++ templates reference template-argument-deduction