Namespaces
Variants

std:: ratio_greater

From cppreference.net
Metaprogramming library
Type traits
Type categories
(C++11)
(C++11) ( DR* )
Type properties
(C++11)
(C++11)
(C++14)
(C++11) (deprecated in C++26)
(C++11) ( until C++20* )
(C++11) (deprecated in C++20)
(C++11)
Type trait constants
Metafunctions
(C++17)
Supported operations
Relationships and property queries
Type modifications
Type transformations
(C++11) (deprecated in C++23)
(C++11) (deprecated in C++23)
(C++11)
(C++11) ( until C++20* ) (C++17)

Compile-time rational arithmetic
Compile-time integer sequences
헤더 파일에 정의됨 <ratio>
template < class R1, class R2 >
struct ratio_greater : std:: integral_constant < bool , /* see below */ > { } ;
(C++11 이후)

비율 R1 이 비율 R2 보다 큰 경우, 멤버 상수 value true 로 설정합니다. 그렇지 않은 경우, value false 입니다.

목차

헬퍼 변수 템플릿

template < class R1, class R2 >
constexpr bool ratio_greater_v = ratio_greater < R1, R2 > :: value ;
(C++17부터)

std:: integral_constant 로부터 상속됨

멤버 상수

value
[static]
true 만약 R1 :: num * R2 :: den > R2 :: num * R1 :: den 이거나 오버플로를 피하는 동등한 표현식일 경우, false 그렇지 않을 경우
(public static member constant)

멤버 함수

operator bool
객체를 bool 로 변환, value 반환
(public member function)
operator()
(C++14)
value 반환
(public member function)

멤버 타입

타입 정의
value_type bool
type std:: integral_constant < bool , value >

예제

#include <iostream>
#include <ratio>
int main()
{
    static_assert(std::ratio_greater<std::ratio<3, 4>, std::ratio<1, 2>>::value,
                  "3/4 > 1/2");
    if (std::ratio_greater<std::ratio<11, 12>, std::ratio<10, 11>>::value)
        std::cout << "11/12 > 10/11" "\n";
    // Since C++17
    static_assert(std::ratio_greater_v<std::ratio<12, 13>, std::ratio<11, 12>>);
    if constexpr (std::ratio_greater_v<std::ratio<12, 13>, std::ratio<11, 12>>)
        std::cout << "12/13 > 11/12" "\n";
}

출력:

11/12 > 10/11
12/13 > 11/12

참고 항목

ratio 객체를 컴파일 타임에 크거나 같음 으로 비교
(클래스 템플릿)