| 11 | } |
| 12 | |
| 13 | int main() |
| 14 | { |
| 15 | std::string s{ "133" }; |
| 16 | |
| 17 | auto pos = FindInStr(s, [](char ch) { |
| 18 | return ch >= '0' && ch <= '9' && (ch - '0') % 2 == 0; |
| 19 | }); |
| 20 | |
| 21 | auto ch = pos.transform([&s](auto idx) { |
| 22 | std::println("The first occurence: {}", s[idx]); |
| 23 | return s[idx]; |
| 24 | }) |
| 25 | .or_else([]() { |
| 26 | std::println("Not find any occurence"); |
| 27 | return std::optional{ '?' }; |
| 28 | }); |
| 29 | |
| 30 | std::println("Get char: {}", *ch); |
| 31 | |
| 32 | return 0; |
| 33 | } |
nothing calls this directly
no test coverage detected