In article
I've had to comment out the line //*it = 8; but the rest works under VC8 and increments the value in the vector:
struct f : public std::unary_function
{ int operator()(int x) const { return ++x; } }; typedef std::vector<int> vec_type; typedef boost::transform_iterator
trans_iter_type; int _tmain(int argc, _TCHAR* argv[]) { 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 above works for me as well. Adding the const qualifier has also solved my original problem. So, operator() must be const qualified. Is that documented somewhere or is it somehow inferrable? Thank you, Nicola