compare_partial_order

compare_partial_order (부분 순서 비교)

이 페이지는 C++20에서 도입된 std::partial_order 사용자 지정 지점 객체에 대해 설명해요. 이 객체는 두 값을 3방향 비교하여 std::partial_ordering 유형의 결과를 생성해요. 부분 순서(partial ordering)를 지원하는 비교를 수행할 때 사용하며, 동등하지 않거나 비교 불가능한 값도 처리할 수 있어요.

출처: cppreference

본문

<compare> 헤더에 정의됨
inline namespace /* unspecified */ { inline constexpr /* unspecified */ partial_order = /* unspecified */ ; } (C++20부터)
호출 서명
template < class T , class U > requires /* see below */ constexpr std :: partial_ordering partial_order ( T && t , U && u ) noexcept ( /* see below */ );

두 값을 3방향 비교(three-way comparison)하여 std::partial_ordering 유형의 결과를 생성합니다.

tu를 표현식이라고 하고, TU가 각각 decltype((t))decltype((u))를 나타낸다고 할 때, std::partial_order(t, u)는 다음 표현식과 동등합니다(expression-equivalent):

  • std::is_same_v<std::decay_t<T>, std::decay_t<U>>true인 경우:
    • std::partial_ordering(partial_order(t, u))std::partial_order의 선언을 포함하지 않는 문맥에서 오버로드 해석을 수행했을 때 잘 구성된 표현식이라면,
    • 그렇지 않으면 std::partial_ordering(std::compare_three_way()(t, u)) — 잘 구성된 표현식이라면,
    • 그렇지 않으면 std::partial_ordering(std::weak_order(t, u)) — 잘 구성된 표현식이라면.
  • 그 외의 모든 경우, 표현식은 잘 구성되지 않으며, 템플릿 인스턴스화의 즉시 문맥(immediate context)에 나타날 때 치환 실패(substitution failure)를 일으킬 수 있습니다.

사용자 지정 지점 객체 (Customization point objects)

std::partial_order라는 이름은 사용자 지정 지점 객체(customization point object)를 나타내며, 이는 리터럴 준정규 타입(literal semiregular type)의 const 함수 객체입니다. 자세한 내용은 CustomizationPointObject를 참고하세요.

예제 (Example)

이 섹션은 불완전합니다. 이유: 예제 없음

같이 보기 (See also)

partial_ordering (C++20) 6개 연산자를 모두 지원하고, 대체 가능(substitutable)하지 않으며, 비교 불가능한 값을 허용하는 3방향 비교의 결과 유형 (클래스) [편집]
strong_order (C++20) 3방향 비교를 수행하고 std::strong_ordering 유형의 결과를 생성 (사용자 지정 지점 객체) [편집]
weak_order (C++20) 3방향 비교를 수행하고 std::weak_ordering 유형의 결과를 생성 (사용자 지정 지점 객체) [편집]
compare_partial_order_fallback (C++20) operator<=>를 사용할 수 없어도 3방향 비교를 수행하고 std::partial_ordering 유형의 결과를 생성 (사용자 지정 지점 객체) [편집]

더 알아보기 (Learn more)

cppreference