String Iterator
-
Abend,
Frage:
Der std::string::iterator ist dass ein Random Access Iterator
oder ein Bidirectional Iterator?gg
-
Probiers aus
#include <iostream> #include <list> void _IteratorTyp(std::random_access_iterator_tag) { std::cout << "random_access" << std::endl; } void _IteratorTyp(std::bidirectional_iterator_tag) { std::cout << "bidirectional" << std::endl; } template<typename T> void IteratorTyp(const T i) { _IteratorTyp(typename std::iterator_traits<T>::iterator_category()); } int main() { IteratorTyp(std::string::iterator()); IteratorTyp(std::list<int>::iterator()); return 0; }
Ausgabe
random_access bidirectional
mfg.