title: Alias a templated function
body: <p>You can use a typedef to create a shorter and simpler name for types:</p>
  
  <pre><code>typedef std::chrono::high_resolution_clock Clock;
  typedef Clock::time_point TimePoint;
  typedef std::chrono::seconds Seconds;
  typedef std::chrono::milliseconds Milliseconds;
  </code></pre>
  
  <p>As well as for instantiated templated types:</p>
  
  <pre><code>typedef std::chrono::duration&lt;float, std::ratio&lt;1&gt;&gt; RealDuration;
  
  // Example usage
  float dt = RealDuration(a - b).count();
  </code></pre>
  
  <p>And for function pointers:</p>
  
  <pre><code>typedef void (*FuncPtr)(int,int);
  </code></pre>
  
  <p>You can also use type aliases for templates:</p>
  
  <pre><code>template&lt;typename T&gt; using uptr = std::unique_ptr&lt;T&gt;;
  
  // Example usage
  uptr&lt;int&gt; myInt;
  uptr&lt;foo&gt; myFoo;
  </code></pre>
  
  <p>But how can you create an alias/pointer to a templated function?  For example, if I want to be able to use the name DurationCast to write things like this:</p>
  
  <pre><code>x = DurationCast&lt;Seconds&gt;(a - b);
  y = DurationCast&lt;Milliseconds&gt;(c - d);
  </code></pre>
  
  <p>What needs to be done to shorten the function <code>std::chrono::duration_cast&lt;T&gt;()</code> to just <code>DurationCast&lt;T&gt;()</code> without simply going the <code>using namespace std::chrono;</code> or <code>using std::chrono::duration_cast;</code> route, and without writing my own function objects to achieve it?</p>
  
  <p><strong>EDIT:</strong>
  I guess I can just write a simple wrapper around it:</p>
  
  <pre><code>template&lt;typename ToType, typename FromType&gt;
  ToType DurationCast(const FromType&amp; d)
  {
      return std::chrono::duration_cast&lt;ToType&gt;(d);
  }
  </code></pre>
  
  <p>Doesn't work like an alias, but the end result is that I can use it in the exact same way I was aiming for:</p>
  
  <pre><code>x = DurationCast&lt;Seconds&gt;(a - b);
  </code></pre>