2022-11-17 15:46:10 +00:00
|
|
|
#ifndef _RSTL_ITERATOR
|
|
|
|
#define _RSTL_ITERATOR
|
|
|
|
|
|
|
|
namespace rstl {
|
|
|
|
|
|
|
|
struct input_iterator_tag {};
|
|
|
|
struct output_iterator_tag {};
|
|
|
|
struct forward_iterator_tag : public input_iterator_tag {};
|
|
|
|
struct bidirectional_iterator_tag : public forward_iterator_tag {};
|
|
|
|
struct random_access_iterator_tag : public bidirectional_iterator_tag {};
|
|
|
|
|
|
|
|
template < typename It >
|
|
|
|
typename It::difference_type __distance(It first, It last, forward_iterator_tag) {
|
|
|
|
typename It::difference_type result = 0;
|
|
|
|
It it = first;
|
|
|
|
while (it != last) {
|
|
|
|
++result;
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
template < typename It >
|
2022-11-27 23:26:24 +00:00
|
|
|
inline typename It::difference_type distance(It first, It last) {
|
2022-11-17 15:46:10 +00:00
|
|
|
return __distance(first, last, typename It::iterator_category());
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace rstl
|
|
|
|
|
|
|
|
#endif // _RSTL_ITERATOR
|