Given a file containing the following hex code: 0B 00 00 00 00 00 20 41
I'm trying to populate an std::vector <std::uint8_t> and then checking each byte manually.
Here's the code where I create my vector from two std::istream_iterators using the iterator constructor
using Bytes = std::vector<std::uint8_t>;
using ByteItr = std::istream_iterator<std::uint8_t>;
Bytes getBytes()
{
std::ifstream in;
in.open("filepath");
in.seekg(0, std::ios::beg);
Bytes bytes;
ByteItr start(in);
ByteItr end;
return Bytes(start, end);
}
Here's the unit test I'm trying to pass it through:
auto bytes = getBytes();
REQUIRE( bytes.size() == 8 );
CHECK( bytes[0] == 0x0B );
CHECK( bytes[1] == 0x00 );
CHECK( bytes[2] == 0x00 );
CHECK( bytes[3] == 0x00 );
CHECK( bytes[4] == 0x00 );
CHECK( bytes[5] == 0x00 );
CHECK( bytes[6] == 0x20 );
CHECK( bytes[7] == 0x41 );
Why is it that in this context, it skips two elements and implicitly converts my vector of std::uint8_t to unsigned chars?