S
sks_cpp
map<int, Drive*> dMap;
list<Drive*> dList;
copy( dMap.begin(), dMap.end(), back_inserter(dList) ); // incorrect
The above will not because value_type of dMap is different than dList.
Now, I would like to wrap the map iterators inside a class class (let's call
it WrapMap)
WrapMap wm(dMap.begin(), dMap.end() );
Now,
copy( wm.begin(), wm.end(), back_inserter(dList) ); // this should work
This means that operator* and operator++ need to be implemented for
"iterator" that is associated with WrapMap. Of course, begin and end should
return the associated WrapMap iterator.
Am I heading in the right direction here? I would like to generalize this
wrapper, iterator, and const_iterator eventually - does anyone have any
ideas?
Thanks.
list<Drive*> dList;
copy( dMap.begin(), dMap.end(), back_inserter(dList) ); // incorrect
The above will not because value_type of dMap is different than dList.
Now, I would like to wrap the map iterators inside a class class (let's call
it WrapMap)
WrapMap wm(dMap.begin(), dMap.end() );
Now,
copy( wm.begin(), wm.end(), back_inserter(dList) ); // this should work
This means that operator* and operator++ need to be implemented for
"iterator" that is associated with WrapMap. Of course, begin and end should
return the associated WrapMap iterator.
Am I heading in the right direction here? I would like to generalize this
wrapper, iterator, and const_iterator eventually - does anyone have any
ideas?
Thanks.