Since you also asked for an explanation
transform_iterator must know the return type of the function called in order to instantiate. This is determined using result_of (found in <boost/utility/result_of.hpp>
If you use a function object, you need to define the result_type member to indicate the type of the result of the object. (since the object does not have a "return type" as such)
If you used a regular function, result_of could figure it out yourself, for example:
template <typename K, typename V> const V & get_value(std::pair<K, V> const & p) { return p.second; } class test { typedef map<int, float> TMap; TMap mymap; public: typedef boost::function< const TMap::mapped_type & (const TMap::value_type &) > F; typedef boost::transform_iterator<F, TMap::iterator> transform_iterator; transform_iterator begin() { return boost::make_transform_iterator(mymap.begin(), &get_value< int, float >); } };
source share