std::ranges...::find_next(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🌸 NAME 🌸

okay so bestie, this page is from the C++ Standard Libary manual (yes, that's literally the spelling in the header β€” we are not fixing it, it's iconic πŸ’…). The NAME section is giving repetitive main character energy:

  • std::ranges::split_view::find_next β€” std::ranges::split_view::find_next (fr fr, the manpage says it twice and we're keeping both).

✨ Synopsis ✨

Here's the signature, copied exactly (the (exposition only*) note is doing a lot of heavy lifting):

constexpr ranges::subrange<ranges::iterator_t<V>>  (exposition only*)
    /*find_next*/( ranges::iterator_t<V> it );

So what does it do? It searches for the next occurrence of pattern in the underlying view πŸ”βœ¨.

bestie, important warning: this function is for exposition only and its name is not normative β€” iykyk, it's an explainer thing, not the real API name. πŸ™ˆ

It's equivalent to this exact code:

auto [b, e] = ranges::search(ranges::subrange(it, ranges::end(base_)),
       pattern_);

if (b != ranges::end(base_) and ranges::empty(pattern_))
{
    ++b;
    ++e;
}

return {b, e};

πŸ’– Parameters πŸ’–

  • it β€” an iterator to the position at which to start the search. That's it, that's the whole parameter list, slay.

πŸŽ€ Return value πŸŽ€

A subrange that represents the next position of the pattern, if it was found. An empty subrange otherwise. So if it finds the pattern? You get the next spot. If not? Empty subrange, bye. πŸ’€


and that's the vibe check, bestie! source/version shoutout: this came from http://cppreference.com, version 2024.06.10, and the footer is still out here saying std::ranges...::find_next(3) β€” iconic. byeee πŸ«Άβœ¨πŸ’…

πŸ“¦ where this page comes from