| 4 | #include <string> |
| 5 | |
| 6 | std::optional<std::size_t> FindInStr(const std::string &str, auto pred) |
| 7 | { |
| 8 | // Of course, you can add std::reference_wrapper. |
| 9 | auto pos = std::ranges::find_if(str, pred); |
| 10 | return pos == str.end() ? std::nullopt : std::optional{ pos - str.begin() }; |
| 11 | } |
| 12 | |
| 13 | int main() |
| 14 | { |