summaryrefslogtreecommitdiff
path: root/src/selectors.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-03-29 20:03:09 +0100
committerMaxime Coste <frrrwww@gmail.com>2015-03-29 20:03:09 +0100
commitadaf6ecc40d91389783e01bd3ac8bca8579f3d28 (patch)
tree1c5161378a9af797ea87f3bf1aa2fbb5cd3bb3df /src/selectors.hh
parent56b5300b9d1a070757855f01fe148274f1904d14 (diff)
Move skip_while helpers to selectors.hh
Diffstat (limited to 'src/selectors.hh')
-rw-r--r--src/selectors.hh14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/selectors.hh b/src/selectors.hh
index 41c7bc96..4ca23030 100644
--- a/src/selectors.hh
+++ b/src/selectors.hh
@@ -18,6 +18,20 @@ inline Selection keep_direction(Selection res, const Selection& ref)
return res;
}
+template<typename Iterator, typename EndIterator, typename T>
+void skip_while(Iterator& it, const EndIterator& end, T condition)
+{
+ while (it != end and condition(*it))
+ ++it;
+}
+
+template<typename Iterator, typename BeginIterator, typename T>
+void skip_while_reverse(Iterator& it, const BeginIterator& begin, T condition)
+{
+ while (it != begin and condition(*it))
+ --it;
+}
+
using Utf8Iterator = utf8::iterator<BufferIterator, utf8::InvalidPolicy::Pass>;
inline Selection utf8_range(const Utf8Iterator& first, const Utf8Iterator& last)