ranges::is_partitioned
ranges::is_partitioned (분할 범위 검사)
범위가 주어진 술어 기준으로 분할되어 있는지 검사하는 ranges 버전 알고리즘이에요. <algorithm> 헤더에 있어요.
출처: cppreference
본문
std::ranges::is_partitioned는 범위가 술어 pred 기준으로 분할(partitioned)되어 있는지 검사해요.
namespace std::ranges {
template< class R, class Proj = std::identity,
std::indirect_unary_predicate<std::projected<ranges::iterator_t<R>, Proj>>
Pred >
constexpr bool is_partitioned( R&& r, Pred pred, Proj proj = {} );
}
- 분할됨 =
pred가 참인 원소들이 거짓인 원소들보다 앞에 옴. - 반환 값: 분할되어 있으면
true.
std::vector<int> v{4, 2, 6, 1, 3};
bool ok = std::ranges::is_partitioned(v, [](int x){ return x % 2 == 0; }); // true
ranges::partition 결과를 검증하거나 분할 전제를 확인할 때 쓰는 ranges 버전이에요.