std::indirectly_comparable

std::indirectly_comparable (간접 비교 가능 컨셉)

두 개의 독립된 범위에 걸쳐 값을 비교하기 위한 기본 알고리즘 요구사항을 명세하는 컨셉이에요. C++20부터 있어요.

출처: cppreference

본문

<iterator> 헤더에 정의돼 있어요.

template< class I1, class I2, class Comp,
          class Proj1 = std::identity, class Proj2 = std::identity >
concept indirectly_comparable =
    std::indirect_binary_predicate<Comp, std::projected<I1, Proj1>, std::projected<I2, Proj2>>;

indirectly_comparable 컨셉은 두 개의 독립된 범위에 걸쳐 값을 비교하기 위한 기본 알고리즘 요구사항을 명세해요. 각 범위에 projection을 적용한 값들을 이항 술어 Comp로 비교할 수 있어야 해요.

의미 요구사항

indirectly_comparable은 그것이 포함하는 모든 컨셉이 모델링될 때만 모델링돼요.

예제

#include <iterator>
#include <vector>
#include <concepts>
#include <functional>

int main()
{
    static_assert(std::indirectly_comparable<std::vector<int>::iterator,
                                             std::vector<int>::iterator,
                                             std::less<>>);
}

더 알아보기 (Learn more)

cppreference