class template
<ratio>

std::ratio_multiply

template <class R1, class R2> ratio_multiply;
Multiply two ratios
This class template alias generates a ratio type that is the multiplication of the ratio types R1 and R2.

The resulting type is the same as if ratio_multiply was defined as:
1
2
template <typename R1, typename R2>
using ratio_multiply = std::ratio < R1::num * R2::num, R1::den * R2::den >;

A program shall not cause any expression in the above definition to expand to values not representable as an intmax_t.

Template parameters

R1,R2
ratio types to be multiplied.

Member constants

The same as ratio (ratio_multiply is merely a template alias).
member constexprdescription
numNumerator
denDenominator

The values of num and den represent the result of the multiplication operation.

Member types

The same as ratio (ratio_multiply is merely a template alias).
member typedefinitiondescription
typeratio<num,den>The ratio type with the result of the multiplication.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// ratio_multiply example
#include <iostream>
#include <ratio>

int main ()
{
  typedef std::ratio<1,2> one_half;
  typedef std::ratio<1,3> one_third;

  typedef std::ratio_multiply<one_half,one_third> result;

  std::cout << "result = " << result::num << "/" << result::den;
  std::cout << " (which is: " << ( double(result::num) / result::den ) << ")" << std::endl;

  return 0;
}

Output:
result = 1/6 (which is: 0.166667)


See also