I wanted to open a file using "ifstream", and then I wanted to read 32
bytes from the file and feed them directly into boost::algorithm::hex.
Unfortunately I couldn't do this because 'hex' takes two iterators
[begin,end), and there's no alternative function "hex_n". So I had to
read the file into a string first, and then pass the string to 'hex'.
- - - - THE IDEA I CAME UP WITH:
Open the file using "ifstream", and then use a special iterator that
will stop reading from the file after 32 bytes, with syntax like this:
&obj_stream, size_t const arg_limit)
: Base(obj_stream), m_limit(arg_limit), m_current_count
/* The initialiser list above does all the construction
istream_iterator_limited(void) /* This gives the End-Of-Stream
: Base() , m_limit(0), m_current_count(1)
/* The initialiser list above does all the construction work