Changeset a44c35d in mainline
- Timestamp:
- 2018-07-05T21:41:20Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0f158be5
- Parents:
- 5072c67
- git-author:
- Dzejrou <dzejrou@…> (2018-04-11 19:14:33)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:20)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/iterator.hpp
r5072c67 ra44c35d 110 110 111 111 /** 112 * 24.4.4, iterator operations 113 */ 114 115 template<class InputIterator, class Distance> 116 void advance(InputIterator& it, Distance n) 117 { 118 for (Distance i = Distance{}; i < n; ++i) 119 ++it; 120 } 121 122 template<class InputIterator> 123 typename iterator_traits<InputIterator>::difference_type 124 distance(InputIterator first, InputIterator last) 125 { 126 using cat_t = typename iterator_traits<InputIterator>::iterator_category; 127 128 if constexpr (is_same_v<cat_t, random_access_iterator_tag>) 129 return last - first; 130 else 131 { 132 cat_t diff{}; 133 while (++first != last) 134 ++diff; 135 } 136 } 137 138 template<class ForwardIterator> 139 ForwardIterator 140 next(ForwardIterator it, typename iterator_traits<ForwardIterator>::difference_type n = 1) 141 { 142 advance(it, n); 143 144 return it; 145 } 146 147 template<class BidirectionalIterator> 148 BidirectionalIterator 149 prev(BidirectionalIterator it, 150 typename iterator_traits<BidirectionalIterator>::difference_type n = 1) 151 { 152 advance(it, -n); 153 154 return it; 155 } 156 157 /** 112 158 * 24.5.1, reverse iterator: 113 159 */
Note:
See TracChangeset
for help on using the changeset viewer.