
On Nov 1, 2011, at 3:26 PM, Olaf van der Spek wrote:
On Tue, Nov 1, 2011 at 9:29 PM, Marshall Clow <mclow.lists@gmail.com> wrote:
You want something like this? template <typename InputIterator, typename OutputIterator> OutputIterator hex ( InputIterator first, InputIterator last, OutputIterator out );
template <typename InputIterator, typename OutputIterator> OutputIterator unhex ( InputIterator first, InputIterator last, OutputIterator out );
[ + range based versions ] [ + versions that work on char/wchar_t/short/int/long/long long, etc]
No, I'm looking for one that returns std::string. Although the generic versions might be useful too.
std::string input ( "61626f6465" ); std::string result; unhex ( input.begin(), input.end (), std::back_inserter(result)); ---> result should contain "abode"
How would your unhex() flag an error?
Throw an exception. -- 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