时,我有以下模板函数:奇怪的错误实例化模板函数
template <std::size_t first, std::size_t last, typename T>
bool in_range(T& in)
{
for(auto i = in.begin(); i!=in.end(); ++i)
if(*i<first || *i>last)
return false;
return true;
}
但是当我尝试使用它作为这样的:
std::vector<int> test;
test.push_back(1);
test.push_back(5);
test.push_back(6);
std::cout<<in_range<4,7>(test);
我得到这个奇怪的错误:
main.cpp: In instantiation of 'bool in_range(T&) [with long long unsigned int first = 4ull; long long unsigned int last = 7ull; T = std::vector<int>]':
main.cpp:31:34: required from here
我在做什么错了?
编辑:全力打造日志:http://pastebin.com/Cwemq2Hk
这真的是完整的错误信息? – 2012-07-06 15:07:25
这是错误消息的一部分,说明发生错误的位置。它会被跟随或之前的错误描述 - 你能发布完整的消息吗? – 2012-07-06 15:09:21
编译精美VC2010,在这里http://ideone.com/yGh30 – hmjd 2012-07-06 15:09:57