Boost logo

Boost :

Subject: Re: [boost] [program_options] Some methods take const char*, others take std::string
From: Yakov Galka (ybungalobill_at_[hidden])
Date: 2011-08-27 04:26:11


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. So do you want to include the null in the
range or not?

Yes, my mistake. When I said 'end() points to' I meant 'end()-1 points to'.

> If you're talking about including or not the null terminator, then I'm
> still
> > not sure on this point. We can say that our strings don't contain zeros
> in
> > the middle (which is acceptable for function expecting const char*), then
> if
>
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.

-- 
Yakov

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