Topic: Are digit characters guaranteed to be consecutive in C++.


Author: kanze@gabi-soft.fr
Date: Tue, 5 Apr 2005 13:33:28 CST
Raw View
In C (   5.2.1/3 in C99), there is a guarantee that "In both the
source and execution basic character sets, the value of each
character after 0 in the above list of decimal digits shall be
one greater than the value of the previous."  I have always
assumed that the same held for C++, but in a recent discussion
in fr.comp.lang.c++, I was unable to find any place in the
standard which guaranteed it; the guarantee is definitely not
present in    2.2, where one would expect it.

Is this intentional, or is this an oversight?

In the discussion, Samuel Krempp pointed out that this guarantee
is given for the results of std::ctype::do_narrow (in
   22.2.1.1.2/13), and that it would be pretty much impossible to
implement this if it didn't hold for the basic execution
character set.  Is it really the intention of the standards
committee that a guarantee concerning the basic language must be
deduced from requirements of a function in the library?  Or is
there a defect somewhere?  (IMHO, either the guarantee should be
added to    2.2, or it should be removed here as well.)

--
James Kanze                                           GABI Software
Conseils en informatique orient   e objet/
                   Beratung in objektorientierter Datenverarbeitung
9 place S   mard, 78210 St.-Cyr-l'   cole, France, +33 (0)1 30 23 00 34


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: rl.news@tempest-sw.com (Ray Lischner)
Date: Wed, 6 Apr 2005 02:43:54 GMT
Raw View
On Tuesday 05 April 2005 03:33 pm, kanze@gabi-soft.fr wrote:

> In C (=C2=A75.2.1/3 in C99), there is a guarantee that "In both the
> source and execution basic character sets, the value of each
> character after 0 in the above list of decimal digits shall be
> one greater than the value of the previous."  I have always
> assumed that the same held for C++, but in a recent discussion
> in fr.comp.lang.c++, I was unable to find any place in the
> standard which guaranteed it; the guarantee is definitely not
> present in =C2=A72.2, where one would expect it.

Fixed in the 2003 standard. Section 2.2, paragraph 3:

"In both the source and execution basic character sets, the value of
each character after 0 in the above list of decimal digits shall be one
greater than the value of the previous."
--=20
Ray Lischner, author of C++ in a Nutshell
http://www.tempest-sw.com/cpp

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: william.m.miller@gmail.com ("William M. Miller")
Date: Wed, 6 Apr 2005 03:55:46 GMT
Raw View
kanze@gabi-soft.fr wrote:
> In C (=A75.2.1/3 in C99), there is a guarantee that "In both the
> source and execution basic character sets, the value of each
> character after 0 in the above list of decimal digits shall be
> one greater than the value of the previous."  I have always
> assumed that the same held for C++, but in a recent discussion
> in fr.comp.lang.c++, I was unable to find any place in the
> standard which guaranteed it; the guarantee is definitely not
> present in =A72.2, where one would expect it.
>=20
> Is this intentional, or is this an oversight?
>=20
> In the discussion, Samuel Krempp pointed out that this guarantee
> is given for the results of std::ctype::do_narrow (in
> =A722.2.1.1.2/13), and that it would be pretty much impossible to
> implement this if it didn't hold for the basic execution
> character set.  Is it really the intention of the standards
> committee that a guarantee concerning the basic language must be
> deduced from requirements of a function in the library?  Or is
> there a defect somewhere?  (IMHO, either the guarantee should be
> added to =A72.2, or it should be removed here as well.)

This is already done (in TC1, aka C++ 2003).  See=20
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#173.

--=20
William M. (Mike) Miller | Edison Design Group, Inc.
william.m.miller@gmail.com

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]