I was going through a code on https://github.com/bitcoin/bitcoin/blob/master/src/uint256.cpp#L23
that traverses array of uint8_t using std::reverse_iterator<const uint8_t*>.
The code snippet is as follows:
#include <stdint.h>
#include <iterator>
#include <iostream>
using namespace std;
uint8_t data[8] = {0, 1, 2, 3, 4, 5, 6, 7};
template<typename T>
void HexStr(const T itbegin, const T itend)
{
for (T it = itbegin; it < itend; ++it)
{
cout << +*it << " ";
}
cout << endl;
}
int main()
{
HexStr(reverse_iterator<const uint8_t*>(data + sizeof(data)),
reverse_iterator<const uint8_t*>(data));
return 0;
}
Why I can not I do the same thing using using a regular iterator (std::iterator<const uint8_t*>.
When I tried, I get the following error:
error: wrong number of template arguments (1, should be at least 2).
Can somebody tell me why this is happening?