
On Wed, Nov 2, 2011 at 8:32 PM, Marshall Clow <mclow.lists@gmail.com> wrote:
AFAIK to hex can't fail and in that case a variant that returns std::string would be nicer.
Sure it can. The container that you are putting it into (std::string, say) could fail on memory allocation. Just because it's really unlikely doesn't mean it can't happen. (If you don't want to worry about it, then don't)
Right, but wouldn't the exception just be propagated to the caller?
Doesn't it 'return' a std::string? If you dislike the current API a small wrapper function can easily handle that.
Right - like this (for example):
std::string hexS ( const std::string &input ) { std::string result; result.reserve ( input.size () * 2 ); // Harry Harrison hex ( input, std::back_inserter ( result )); return result; }
Yep, except that it should not be limited to std::string. Olaf