Boost logo

Boost :

Subject: Re: [boost] hex/unhex()?
From: Marshall Clow (mclow.lists_at_[hidden])
Date: 2012-06-03 01:39:29


On Jun 2, 2012, at 12:32 PM, Olaf van der Spek wrote:

> On Wed, Feb 29, 2012 at 12:19 AM, Marshall Clow <mclow.lists_at_[hidden]> wrote:
>> On Nov 1, 2011, at 1:09 PM, Olaf van der Spek wrote:
>>>
>>> Does Boost have hex/unhex() that support std::string?
>>> I can't find them and I think they'd be quite handy to have.
>>
>> Committed in revision 77138
>
> Thanks. Got some questions though:
> 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));

> Should hex output be upper case or lower case? c++0x suggests lower case. :p
>
> Shouldn't hex_decode_error derive from std::runtime_error?

Yes, it probably should.

> Wouldn't it be simpler to only provide the range-based variant and
> require C strings and iterator pairs to be wrapped in a range?

Simpler, yes.
Easier to use, I think not.

-- Marshall

Marshall Clow Idio Software <mailto:mclow.lists_at_[hidden]>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
        -- Yu Suzuki


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk