Boost logo

Boost :

From: depdev.sdi_at_[hidden]
Date: 2002-10-22 10:44:46


On 22 Oct 2002 at 22:18, Joel de Guzman wrote:
[...]
> > The only comment I have of relevance is the use of range_p( ch_first, ch_last ).
> > As the type char is signed, a range like [ '\xC0', '\xC4' ] throws an assertion error
> > (ch_last less than ch_first). Another example is range_p( '\x21', '\xFF' ), for all non
> > control chars (in 8-bit latin1).
> >
> > I understand that this can be a litle controverse as the type is signed (for the majority of
> > the compilers), but I think it is more natural if the range could be unsigned (at least for
> > foreign users like me that use more than 7-bit chars).
>
> Use unsigned char:
>
> unsigned char ch_first = '\x21';
> unsigned char ch_last = \xFF';
> range_p(ch_first, ch_last);

Well, I should be punished for not going through the code to see that..
I'm now at work so I don't have the code here now, but your solution
still doesn't is what I expected.
On a grammar you would have to code like this,

 nonctl_char = range_p( (unsigned char)'\x21', (unsigned char)'\xFF' );

And I think this is a little ugly (and a temp var isn't beautifaul, either).
So I maintain that it is more natural to just say:

  nonctl_char = range_p( '\x21', '\xFF' );

This would imply that the internal test on range_p() would first
transform the arguments to unsigned char.

As I said before, I know this can be a bit controversial. It's just an idea
open for discussion...

>
> HTH,
> --Joel
>

Regards,

    ~Nuno Lucas

--------------------
SDI - Sistemas e Desenvolvimento Informático
Rua Nova da Estação, 315 -- 4710-234 Braga
Tel: 253 268 690/1 Fax: 253 268 692


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