Solutions
23. Binary to string conversion
In order to write a general-purpose function that can handle various sorts of ranges, such as an std::array, std::vector, a C-like array, or others, we should write a function template. In the following, there are two overloads; one that takes a container as an argument and a flag indicating the casing style, and one that takes a pair of iterators (to mark the first and then one past the end element of the range) and the flag to indicate casing. The content of the range is written to an std::ostringstream object, with the appropriate I/O manipulators, such as width, filling character, or case flag:
template <typename Iter>
std::string bytes_to_hexstr(Iter begin, Iter end,
...