title: How to use std::iterator with basic type uint8_t*?
body: <p>In Bitcoin Core C++ implementation there is the <a href="https://github.com/bitcoin/bitcoin/blob/master/src/uint256.cpp#L23" rel="nofollow noreferrer">code</a> that traverses array of uint8_t using <code>std::reverse_iterator&lt;const uint8_t*&gt;</code>.</p>
  
  <p>See the simplified code below and also in <a href="https://pastebin.com/2vVGpUFZ" rel="nofollow noreferrer">pastebin</a>.</p>
  
  <pre><code>#include &lt;stdint.h&gt;
  #include &lt;iterator&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  uint8_t data[8] = {0, 1, 2, 3, 4, 5, 6, 7};
  
  template&lt;typename T&gt;
  void HexStr(const T itbegin, const T itend)
  {
      for (T it = itbegin; it &lt; itend; ++it)
      {
          cout &lt;&lt; +*it &lt;&lt; " ";
      }
      cout &lt;&lt; endl;
  }
  
  int main()
  {
      HexStr(reverse_iterator&lt;const uint8_t*&gt;(data + sizeof(data)),
             reverse_iterator&lt;const uint8_t*&gt;(data));
  
      return 0;
  }
  </code></pre>
  
  <p>My question is why the same <em>cannot</em> be done using a regular iterator (<code>std::iterator&lt;const uint8_t*&gt;</code>) - the compiler error is <code>error: wrong number of template arguments (1, should be at least 2)</code>.</p>
  
  <p>See the failing code in this <a href="https://pastebin.com/gwYbDGgv" rel="nofollow noreferrer">pastebin</a>.</p>
  
  <p>The code can be copied and compiled online here: <a href="http://www.compileonline.com/compile_cpp11_online.php" rel="nofollow noreferrer">http://www.compileonline.com/compile_cpp11_online.php</a></p>