title: How do I use ratio Instead of a float?
body: <p>So I know that I cannot use a <code>float</code> as a template parameter:<strike></p>
  
  <pre><code>template&lt;float T&gt;
  float foo(const float param) { return param + T; }
  </code></pre>
  
  <p></strike>I've heard that <a href="https://en.cppreference.com/w/cpp/numeric/ratio/ratio" rel="nofollow noreferrer"><code>ratio</code></a> can be used as an alternative. I'd like to do something like this:<strike></p>
  
  <pre><code>template&lt;ratio T&gt;
  float foo(const float param) { return param * T::num / static_cast&lt;float&gt;(T::den); }
  </code></pre>
  
  <p></strike>Unfortunately <code>ratio</code> is not a complete type so that doesn't work at all. And ultimately I have to ask, why not just do:</p>
  
  <pre><code>template&lt;int Num, int Denom&gt;
  float foo(const float param) { return param * Num / static_cast&lt;float&gt;(Denom); }
  </code></pre>
  
  <p>My preference would be to use a <code>ratio</code> because it more clearly represents what I'm trying to do. Could someone provide me a simple way to use <code>ratio</code>?</p>