I have an STL map that uses a structure as a key:
I want to access every member of the map without regard to the key value, so I tried:Code:typedef struct _RC_ { UINT R; UINT C; } RC; typedef struct _Data_ { int data1; int data2; } DATA; struct _RC_Compare { bool operator() ( const RC p1, const RC p2 ) const { return p1.R == p2.R? p1.C < p2.C : p1.R < p2.R; } typedef std::map< RC, DATA, _RC_Compare > MY_MAP
When this executes, it termiantes with the message "map/set iterator not incrementable" when it tries to execute the "++it".Code:MY_MAP::iterator it; for( it = MY_MAP.begin(); it != MY_MAP.end(); ++it ) { // Bunch of code having nothing to do with the map }
Why can't I sequentially access a map? Everything I've read indicates this is possible, although all the examples have C++ primitives as keys.




Reply With Quote