How to write a function that takes any std::chrono::duration (1ms, 4s, 7h) and gets the seconds as a float?
<p>Even just trying to get started, I get an error with this code:  </p>

<pre><code>note: candidate template ignored: could not match 'double' against 'long'
</code></pre>

<p>::</p>

<pre><code>#include &lt;numeric&gt;
#include &lt;chrono&gt;
using namespace std::chrono_literals;

// how to write a function that will take any duration and turn it 
//   into a float representation of seconds?
template &lt;class T&gt;
void go(std::chrono::duration&lt;double, T&gt; d) {

    // what I want to do (that may not work because I haven't gotten this far):
    float seconds = std::chrono::duration_cast&lt;std::chrono::seconds&gt;(d);
}

int main()
{
  go(1ms);
  go(1s);
}
</code></pre>