This adds support for some common functional style operations that allow you to take or drop characters until a certain condition is met.
Example:
assert(StringRef("ABCD2908XYZ".take_while([](char c) { return ::is_hexdigit(c); }) == "XYZ");
Paths
| Differential D24842
Add StringRef {take, drop} x {_while, _until} ClosedPublic Authored by zturner on Sep 22 2016, 1:47 PM.
Details Summary This adds support for some common functional style operations that allow you to take or drop characters until a certain condition is met. Example: assert(StringRef("ABCD2908XYZ".take_while([](char c) { return ::is_hexdigit(c); }) == "XYZ");
Diff Detail Event Timelinezturner updated this object. This revision is now accepted and ready to land.Sep 22 2016, 2:00 PM
Comment Actions Have you considered adding StringRef(iterator, iterator) constructor, and replacing the explicit loops with std::find_if and std::find_if_not. zturner edited edge metadata. Comment ActionsAdded find_if and made the drop and take functions use that. Comment Actions lgtm modulo minor comments
Closed by commit rL282346: Add some predicated searching functions to StringRef. (authored by zturner). · Explain WhySep 24 2016, 8:36 PM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 72372 include/llvm/ADT/StringRef.h
unittests/ADT/StringRefTest.cpp
|
Docs?