title: How to get elapsed time in seconds from boost::timer::cpu_timer?
body: <p>The following rough code, based on <a href="http://www.boost.org/doc/libs/1_48_0/libs/timer/doc/cpu_timers.html" rel="noreferrer">the documentation</a>, gives me the elapsed time in seconds from the timer object provided in boost.</p>
  
  <pre><code>boost::timer::cpu_timer timer;
  // ...do some work...
  const boost::timer::nanosecond_type oneSecond(1000000000LL);
  return timer.elapsed().user / oneSecond;
  </code></pre>
  
  <p>The problem with this method is that I have this uncomfortable magic number in my code. Is there some method within boost that can give me <em>elapsed seconds</em> out of the <strong>nanosecond_type</strong> value available from the call to <strong>elapsed().user</strong>, without having this magic number sitting in my code?</p>
  
  <p><strong>(EDIT:) Conclusion:</strong></p>
  
  <p>Based on the accepted answer, I ended up with this snippet in my production code:</p>
  
  <pre><code>boost::timer::cpu_timer timer;
  // ...do some work...
  auto nanoseconds = boost::chrono::nanoseconds(timer.elapsed().user + timer.elapsed().system);
  auto seconds = boost::chrono::duration_cast&lt;boost::chrono::seconds&gt;(nanoseconds);
  std::cout &lt;&lt; seconds.count() &lt;&lt; std::endl;
  </code></pre>