| 446 | |
| 447 | template <class Predicate> |
| 448 | static inline bool UTF8FindIf(const uint8_t* first, const uint8_t* last, |
| 449 | Predicate&& predicate, const uint8_t** position) { |
| 450 | const uint8_t* i = first; |
| 451 | while (i < last) { |
| 452 | uint32_t codepoint = 0; |
| 453 | const uint8_t* current = i; |
| 454 | if (ARROW_PREDICT_FALSE(!UTF8Decode(&i, &codepoint))) { |
| 455 | return false; |
| 456 | } |
| 457 | if (predicate(codepoint)) { |
| 458 | *position = current; |
| 459 | return true; |
| 460 | } |
| 461 | } |
| 462 | *position = last; |
| 463 | return true; |
| 464 | } |
| 465 | |
| 466 | // Same semantics as std::find_if using reverse iterators with the return value |
| 467 | // having the same semantics as std::reverse_iterator<..>.base() |