我正在使用boost 1.52和Visual Studio 2010。
我想知道为什么我无法强制执行boost::adaptors::indirected
返回的元素。
此示例代码显示了我正在尝试实现的目标:
#include <vector>
#include <string>
#include <boost/range/adaptor/indirected.hpp>
#include <boost/foreach.hpp>
int main() {
using std::vector;
using std::string;
typedef vector<string*> type;
type range;
range.push_back(new string("42"));
type const& const_range = range;
// This is ok to compile
BOOST_FOREACH(string const& foo, const_range | boost::adaptors::indirected) {
//...
}
// I don't want this to compile
BOOST_FOREACH(string& foo, const_range | boost::adaptors::indirected) {
//...
}
return 0;
}