
On Jun 3, 2012, at 4:35 AM, Olaf van der Spek wrote:
On Sun, Jun 3, 2012 at 7:39 AM, Marshall Clow <mclow.lists@gmail.com> wrote:
What if input type is like range<char*> (and you'd like output type to be std::string)? I think output type and input type shouldn't be required to be equal.
They don't have to be equal. std::string s; hex ( <range>, std::back_inserter (s));
But that's not as convenient as the normal function which returns the string.
Indeed. My goal is not to provide every possible convenience function; the goal is to provide a functionality that can be used in a wide variety of circumstances. If you have a need for such a function, I am confident that you can write it.
It's also missing reserve().
reserve is not appropriate in this case; since in general, the size of the input range cannot be determined easily. For a null terminated string, you would have to traverse the input twice; once to determine the length, and the other to do the conversion. That might be advantageous (or not); but consider in the case where the input range is a pair of input iterators.
Should hex output be upper case or lower case? c++0x suggests lower case. :p
MySQL (and inertia) suggest upper case; note that unhex will accept both. -- Marshall Marshall Clow Idio Software <mailto:mclow.lists@gmail.com> A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait). -- Yu Suzuki