std::indirect_unary_predicate
std::indirect_unary_predicate (간접 단항 술어 컨셉)
인자로 단항 술어를 호출하는 알고리즘에 대한 요구사항을 명세하는 컨셉이에요. std::predicate와 달리 I 자체가 아니라 I가 참조하는 타입에 적용돼요. C++20부터 있어요.
출처: cppreference
본문
<iterator> 헤더에 정의돼 있어요.
template< class F, class I >
concept indirect_unary_predicate =
std::indirectly_readable<I> &&
std::copy_constructible<F> &&
std::predicate<F&, /*indirect-value-t*/<I>> &&
std::predicate<F&, std::iter_reference_t<I>>;
/*indirect-value-t*/의 정의는 이 페이지를 참조해요. indirect_unary_predicate 컨셉은 인자로 단항 술어를 호출하는 알고리즘에 대한 요구사항을 명세해요. 이 컨셉과 std::predicate의 핵심 차이는 I 자체가 아니라 I가 참조하는 타입에 적용된다는 점이에요.
결함 보고
P2609R3(C++20) — 요구사항 중 하나가 std::iter_value_t<I>&로 정의되어 projection을 잘못 처리해, std::reference_wrapper 등과 호환되지 않았음. /*indirect-value-t*/로 수정됨.
예제
#include <iterator>
#include <vector>
#include <concepts>
#include <functional>
int main()
{
static_assert(std::indirect_unary_predicate<std::less<int>,
std::vector<int>::iterator>);
}