Open main menu

Difference between revisions of "TODO"

434 bytes added ,  16:17, 23 November 2007
m
(→‎General: Add TODO entries concerning our iterator implementation)
m (→‎Iterator handling: clarification)
Line 66: Line 66:
It will fail with (i.e. gcc 4.2.3):
It will fail with (i.e. gcc 4.2.3):
     error: conversion from ‘Common::List<int>::Iterator<int>’ to non-scalar type ‘Common::List<int>::Iterator<const int>’ requested
     error: conversion from ‘Common::List<int>::Iterator<int>’ to non-scalar type ‘Common::List<int>::Iterator<const int>’ requested
This is since our Common::List::Iterator implementation does not supply a copy constructor from Common::List::Iterator<int> to the specific type. Check for example Common::HashMap::Iterator for a (rather hacky) implementation of it, or [http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/stl__tree_8h-source.html#l00221 the GNU libstdc++ implementation] (example for std::map iterators).
To understand what is wrong you have to know that C++ does not support function overloading by return value, so it picks 'iterator Common::List<T>::begin' (NOT the implementation for constant instances of the type, since 'list' is not const in this example) instead of 'const_iterator Common::List<T>::begin' (the one for constant instances of the type). This is no problem at all for the STL, but since our 'Common::List::Iterator' implementation does not supply a copy constructor from 'Common::List<T>::Iterator<t_T2>' to 'Common::List<T>::Iterator<const t_T2>', it will fail. Check for example Common::HashMap::Iterator for a (rather hacky) implementation of it, or [http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/stl__tree_8h-source.html#l00221 the GNU libstdc++ implementation] (example for std::map iterators).
* Implement proper reverse_iterators for Common::List. Our current implementation is the same as forward iterators, just that rbegin will return the last element instead of the first and there is no rend. Check [http://www.sgi.com/tech/stl/ReverseIterator.html SGI Documentation] for proper description of revese_iterator in the STL.
* Implement proper reverse_iterators for Common::List. Our current implementation is the same as forward iterators, just that rbegin will return the last element instead of the first and there is no rend. Check [http://www.sgi.com/tech/stl/ReverseIterator.html SGI Documentation] for proper description of revese_iterator in the STL.


561

edits