diff --git a/view.hpp b/view.hpp index 3b204046..068f6332 100644 --- a/view.hpp +++ b/view.hpp @@ -750,6 +750,27 @@ namespace cruft { } + /////////////////////////////////////////////////////////////////////////// + template + std::pair, view> + split_on ( + view const buffer, + typename std::iterator_traits::value_type const value + ) { + auto const pos = std::find (std::begin (buffer), std::end (buffer), value); + if (pos == std::end (buffer)) + return { + buffer, + {std::end (buffer), std::end (buffer)} + }; + + return { + { buffer.begin (), pos, }, + { pos + 1, buffer.end () } + }; + } + + /////////////////////////////////////////////////////////////////////////// /// Returns a reference to a value of the designated type at the front of /// the word-view. if there is insufficient data for the extraction an