1
下面的代码失败下克++编译,用下面的错误:找到的模板的模板功能否匹配
“为调用没有匹配的函数‘GetRecById(INT &,NULL)’”:
template < typename T >
struct DummyLookup
{
static bool DoLookup(T& rec, const char* id)
{
rec = 123;
return true;
}
};
template < typename T,
template <class> class LookupPolicy
>
static bool GetRecById(T& rec, const char* id)
{
return LookupPolicy<T>::DoLookup(rec, id);
}
static void testLookup(void)
{
int rec = 0;
const bool ret = GetRecById< int, DummyLookup<int> >(rec, NULL);
std::cout << "rec = " << rec << std::endl; // should be 123
}
int main()
{
testLookup();
return 0;
}
意图是GetRecById()支持用不同的记录查询策略实例化为单元测试目的。
我在这里做错了什么? FWIW,它在Sun Studio 10下编译。
在此先感谢。