c++ - transform_iterator compile problem -


Hi,

I do not like posting compiled problems, but I can not really understand this one out. Using this code:

  #include & lt; Map & gt; #include & lt; Boost / iterator / transform_iterator.hpp & gt; using namespace std; Template & lt; Typename K, typename V & gt; Struct get_value {Const V & amp; Operator () (STD :: Jodi and LT; K, V & P; Const & P) {Return P. Sext; }}; Classroom trial {typedef map & lt; Int, float & gt; TMap; TMAP Mimeup; Public: typedef get_value & lt; TMap :: key_type, TMap :: value_type & gt; F, Type-Ff boost :: Transformer & lt; F, TMap :: Iterator & gt; Transform_iterator; Transformer start () {return make_transform_iterator (mymap.begin (), F ()); }};  

This compilation error is coming:

  transform_iterator.hpp (43): error C2039: 'RESULT_TYPE': does not get_value & lt A member, K, V & gt; With [K = int, V = std :: pair and lt; Const int, float & gt; ] Can anyone explain why this is not working? I am using 1.36.0 with the promotion of Visual Studio 7.0  

Thanks.

Since you also have explanation

transform_iterator Need to know the return type of the function that is called in order to instantiate itself, boost / utility / result_of.hpp & gt; It is determined through found in <(> code> & lt)

If you use a function object, you need to define a member RESULT_TYPE object.

If you want to have used a regular function, then result_of will be able to find it on its own, like:

  template  constants & amp; p) {return p.second;} class test {typedef map  int , Float> TMap; TMap mymap; public: typedef boost :: function & lt; const TMap :: map_type & amp; (const TMap :: value_type & amp;); f; promote typedef :: Transform_iterator & lt; f, TMap :: iterator & gt; transform_iterator; start transform_iterator () {return promotion :: make_transform_iterator (mymap.begin (), & amp; get_value & lt; integer, float & gt;);}};  

Comments