考虑这个基于Boost.Range和C ++ 11范围的循环使用,它不能用MSVS 2012进行编译:
#include <iostream>
#include <vector>
#include <boost/container/vector.hpp>
#include <boost/range/algorithm/find.hpp>
int main()
{
std::vector<int> vec;
for(auto i : boost::find(vec, 1))
{
std::cout << "lolwut";
}
return 0;
}
编译器输出:
1>...\main.cpp(10): error C3312: no callable 'begin' function found for type 'boost::container::container_detail::vector_iterator<Pointer>'
1> with
1> [
1> Pointer=int *
1> ]
1>...\main.cpp(10): error C3312: no callable 'end' function found for type 'boost::container::container_detail::vector_iterator<Pointer>'
1> with
1> [
1> Pointer=int *
1> ]
1>
1>Build FAILED.
Boost.Range不能在基于范围的for循环中使用?或者我做错了什么?谢谢!