ranges::find_first_of

ranges::find_first_of (집합 원소 첫 등장)

범위에서 두 번째 범위(집합)에 속한 원소 중 가장 먼저 등장하는 것을 찾는 ranges 버전 알고리즘이에요. <algorithm> 헤더에 있어요.

출처: cppreference

본문

std::ranges::find_first_of[first1, last1) 안에서 [first2, last2)에 속한 원소가 처음 등장하는 위치를 찾아요.

namespace std::ranges {
template< std::forward_iterator I1, std::sentinel_for<I1> S1,
          std::forward_iterator I2, std::sentinel_for<I2> S2,
          class Pred = ranges::equal_to, class Proj1 = std::identity,
          class Proj2 = std::identity >
constexpr I1 find_first_of( I1 first1, S1 last1, I2 first2, S2 last2,
                            Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {} );
}
  • 반환 값: [first2, last2)에 속한 원소 중 첫 등장 위치. 없으면 last1.
std::string s = "Hello World";
auto it = std::ranges::find_first_of(s, "aeiou");   // 'e'의 위치

찾고 싶은 "집합" 중 먼저 나오는 것을 찾을 때 유용해요.

더 알아보기 (Learn more)

cppreference