I like to write container agnostic code that uses std
methods like std::distance()
or std::advance()
in my code. This is useful for deserialization where I can pass in buffer objects of different types (network stream, byte stream, ...).
How can I convert char*
or uint8_t*
pointers to an iterator? Copying the data to a buffer is not an option.
One option I have in mind is to use a custom allocator with std::string
but I'd prefer a more ready made solution if available.
Any suggestions?