【发布时间】:2012-07-01 23:24:33
【问题描述】:
所以,我创建了一个包含以下内容的头文件:
namespace A
{
template<int a>
void foo(...)
{
//This throws a "test was not declared in this scope" error:
boost::function< bool (int, int)> t = test<a>;
}
template<int a>
bool test(int c, int d)
{
//Do stuff;
}
}
但是,编译时抛出错误,我不知道为什么。测试显然在范围内。
用boost:ref(test<a>) 或&test<a> 替换test<a> 仍然不起作用。
有什么想法吗?
【问题讨论】:
-
你需要一个
test的前向声明,就像你对任何其他函数一样。 -
我不敢相信我错过了显而易见的......谢谢。
标签: c++ templates namespaces compiler-errors boost-function