Created
June 23, 2018 21:50
-
-
Save qrealka/b1d113d7a76b6a39688f905078745b5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <class I, // I models ForwardIterator | |
class P, // P is binary predicate (value_type(I), value_type(I)) -> bool | |
class O> // O is a function (I, I) -> void | |
auto split(I begin, I end, P predicate, O subsequnce) -> O { | |
while(begin != end) { | |
auto split_pos = std::adjacent_find(begin, end, predicate); | |
if (split_pos != end) ++split_pos; | |
subsequnce(begin, split_pos); | |
begin = split_pos; | |
} | |
return subsequnce; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment