# std::ratio_equal

< cpp‎ | numeric‎ | ratio

C++
 Language Standard library headers Concepts Utilities library Strings library Containers library Algorithms library Iterators library Numerics library Input/output library Localizations library Regular expressions library (C++11) Atomic operations library (C++11) Thread support library (C++11) Filesystem library (C++17) Technical Specifications

Numerics library
 Common mathematical functions Special mathematical functions Floating-point environment (C++11) Complex numbers Numeric arrays Pseudo-random number generation Compile-time rational arithmetic (C++11) Generic numeric operations iota(C++11) accumulate inner_product adjacent_difference partial_sum

Compile time rational arithmetic
 ratio(C++11) Arithmetic ratio_add(C++11) ratio_subtract(C++11) ratio_multiply(C++11) ratio_divide(C++11) Comparison ratio_equal(C++11) ratio_not_equal(C++11) ratio_less(C++11) ratio_less_equal(C++11) ratio_greater(C++11) ratio_greater_equal(C++11)

<td>
Defined in header `<ratio>`
</td>

<td></td> <td></td> </tr> <tr class="t-dcl ">

template< class R1, class R2 >
struct ratio_equal : std::integral_constant;
</td>

If the ratios R1 and R2 are equal, provides the member constant `value` equal true. Otherwise, `value` is false.

## Inherited from std::integral_constant

### Member constants

 value[static] true if R1::num == R2::num && R1::den == R2::den , false otherwise (public static member constant)

### Member functions

 operator bool converts the object to bool, returns `value` (public member function) operator()(C++14) returns `value` (public member function)

### Member types

 Type Definition `value_type` `bool` `type` std::integral_constant

### Possible implementation

 ```template< class R1, class R2 > struct ratio_equal : public std::integral_constant < bool, R1::num == R2::num && R1::den == R2::den > {};```

### Example

```#include <iostream>
#include <ratio>

int main()
{
if(std::ratio_equal<std::ratio<2,3>, std::ratio<4,6>>::value) {
std::cout << "2/3 == 4/6\n";
} else {
std::cout << "2/3 != 4/6\n";
}
}```

Output:

`2/3 == 4/6`