Boost logo

Boost :

Subject: Re: [boost] [program_options] Some methods take const char*, others take std::string
From: Olaf van der Spek (ml_at_[hidden])
Date: 2011-08-27 06:00:57


On Sat, Aug 27, 2011 at 10:26 AM, Yakov Galka <ybungalobill_at_[hidden]> wrote:
> On Wed, Aug 24, 2011 at 22:22, Olaf van der Spek <ml_at_[hidden]> wrote:
>
>> On Wed, Aug 24, 2011 at 5:27 PM, Yakov Galka <ybungalobill_at_[hidden]>
>> wrote:
>> > 2) Yes, it treats string literals as arrays, so what? It's exactly what
>> we
>> > want.
>>
>> No, because it'll include the null terminator.
>> [...]
>> end() will point one past the terminator.
>>
>
> The two are exactly opposite.

No they're not. end() is not included in the range, so if end() points
to one past the terminator, the terminator is part of the range.
if end() points to the terminator, the terminator is not part of the range.

> So do you want to include the null in the
> range or not?

I don't.

> It'd be nice to support 'binary' strings too.
>>
>
> I remember that you brought up this topic some time ago. However I don't
> think that you need anything special to handle binary chunks of data:
>
> typedef iterator_range<const char*> data_ref;
>
> Unlike for str_ref, this *is* a complete, working implementation.

The parameter types are usually (const void*, size_t). Not const char*.

Olaf


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