title: How is std::advance implemented to change behavior on iterator type?
body: <p>What we know about <code>std::advance</code> is the following:</p>
  
  <pre><code>template &lt;class InputIterator, class Distance&gt;
  void advance (InputIterator&amp; i, Distance n);
  </code></pre>
  
  <p><strong>Purpose</strong></p>
  
  <p>Advances the iterator <code>i</code> by <code>n</code> elements.</p>
  
  <p><em>If <code>i</code> is a Random Access Iterator, the function uses once <code>operator+</code> or <code>operator-</code>, otherwise, the function uses repeatedly the increase or decrease operator (<code>operator++</code> or <code>operator--</code>) until <code>n</code> elements have been advanced.</em></p>
  
  <hr>
  
  <p>My question is the following:
  How is <code>std::advance</code> implemented such that it recognizes if <code>it</code> is a Random Access Iterator or not? How does it know it can use <code>operator+</code> instead of <code>operator++</code>?</p>