
Hello, I cannot figure out why the following code is wrong: #include <iostream> #include <vector> #include <functional> #include <boost/iterator/transform_iterator.hpp> struct f : public std::unary_function<int, int&> { int& operator()(int& x) { return x; } }; typedef std::vector<int> vec_type; typedef boost::transform_iterator<f, vec_type::iterator> trans_iter_type; int main() { vec_type V; V.push_back(4); trans_iter_type it(boost::make_transform_iterator(V.begin(), f())); std::cout << *it << std::endl; *it = 8; std::cout << *it << std::endl; return 0; } The compiler (g++ 4.0.1) complains about dereferencing and the error message says: error: passing ‘const f’ as ‘this’ argument of ‘int& f::operator()(int&)’ discards qualifiers Nicola