Topic: N3639 bad_array_length vs size
Author: Olaf van der Spek <olafvdspek@gmail.com>
Date: Wed, 5 Feb 2014 03:09:29 -0800 (PST)
Raw View
------=_Part_95_7743257.1391598569723
Content-Type: text/plain; charset=UTF-8
> The class bad_array_length defines the type of objects thrown as
exceptions by the implementation to report an attempt to allocate an array
of runtime bound with a size less than or equal to zero or greater than an
implementation-defined limit (8.3.4 dcl.array).
Shouldn't this be named bad_array_size?
The description talks about size and containers use size(). Only string has
length() AFAIK.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_95_7743257.1391598569723
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><span style=3D"color: rgb(0, 0, 0); font-family: 'Times Ne=
w Roman'; font-size: medium;">> The class </span><code style=3D"col=
or: rgb(0, 0, 0);">bad_array_length</code><span style=3D"color: rgb(0, 0, 0=
); font-family: 'Times New Roman'; font-size: medium;"> defines the ty=
pe of objects thrown as exceptions by the implementation to report an attem=
pt to allocate an array of runtime bound with a size less than or equal to =
zero or greater than an implementation-defined limit (8.3.4 dcl.array).</sp=
an><br><div><span style=3D"color: rgb(0, 0, 0); font-family: 'Times New Rom=
an'; font-size: medium;"><br></span></div><div><span style=3D"color: rgb(0,=
0, 0); font-family: 'Times New Roman'; font-size: medium;">Shouldn't this =
be named bad_array_size? </span></div><div><span style=3D"color: rgb(0=
, 0, 0); font-family: 'Times New Roman'; font-size: medium;">The descriptio=
n talks about size and containers use size(). Only string has length() AFAI=
K.</span></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_95_7743257.1391598569723--
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Wed, 5 Feb 2014 10:02:55 -0800
Raw View
--047d7b41454ef86c7304f1ac902c
Content-Type: text/plain; charset=ISO-8859-1
On Wed, Feb 5, 2014 at 3:09 AM, Olaf van der Spek <olafvdspek@gmail.com>wrote:
> > The class bad_array_length defines the type of objects thrown as
> exceptions by the implementation to report an attempt to allocate an array
> of runtime bound with a size less than or equal to zero or greater than an
> implementation-defined limit (8.3.4 dcl.array).
>
> Shouldn't this be named bad_array_size?
> The description talks about size and containers use size(). Only string
> has length() AFAIK.
>
An array is not a container. For arrays, the core language calls the number
of elements the 'bound' (see [dcl.array]p1), so bad_array_bound would be
more appropriate. However, the standard library (since C++11) already has a
std::bad_array_new_length exception, and consistency with that seems more
important, so std::bad_array_length is the right name. The standard library
also has std::extent, std::remove_extent, and std::remove_all_extents, so
it's not even self-consistent. It's too late to fix this mess. :(
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--047d7b41454ef86c7304f1ac902c
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On W=
ed, Feb 5, 2014 at 3:09 AM, Olaf van der Spek <span dir=3D"ltr"><<a href=
=3D"mailto:olafvdspek@gmail.com" target=3D"_blank">olafvdspek@gmail.com</a>=
></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex"><div dir=3D"ltr"><span style=3D"font-size:medium;font-fami=
ly:'Times New Roman'">> The class=A0</span><code style>bad_array=
_length</code><span style=3D"font-size:medium;font-family:'Times New Ro=
man'">=A0defines the type of objects thrown as exceptions by the implem=
entation to report an attempt to allocate an array of runtime bound with a =
size less than or equal to zero or greater than an implementation-defined l=
imit (8.3.4 dcl.array).</span><br>
<div><span style=3D"font-size:medium;font-family:'Times New Roman'"=
><br></span></div><div><span style=3D"font-size:medium;font-family:'Tim=
es New Roman'">Shouldn't this be named bad_array_size?=A0</span></d=
iv>
<div><span style=3D"font-size:medium;font-family:'Times New Roman'"=
>The description talks about size and containers use size(). Only string ha=
s length() AFAIK.</span></div></div></blockquote><div><br></div><div>An arr=
ay is not a container. For arrays, the core language calls the number of el=
ements the 'bound' (see [dcl.array]p1), so bad_array_bound would be=
more appropriate. However, the standard library (since C++11) already has =
a std::bad_array_new_length exception, and consistency with that seems more=
important, so std::bad_array_length is the right name. The standard librar=
y also has std::extent, std::remove_extent, and std::remove_all_extents, so=
it's not even self-consistent. It's too late to fix this mess. :(<=
/div>
</div></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--047d7b41454ef86c7304f1ac902c--
.
Author: potswa@gmail.com
Date: Thu, 6 Feb 2014 15:01:11 +0800
Raw View
--Apple-Mail=_7640E05C-C025-4410-8AFF-D5034260C7CF
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1
On Feb 6, 2014, at 2:02 AM, Richard Smith <richard@metafoo.co.uk> wrote:
> On Wed, Feb 5, 2014 at 3:09 AM, Olaf van der Spek <olafvdspek@gmail.com> =
wrote:
> > The class bad_array_length defines the type of objects thrown as except=
ions by the implementation to report an attempt to allocate an array of run=
time bound with a size less than or equal to zero or greater than an implem=
entation-defined limit (8.3.4 dcl.array).
>=20
> Shouldn't this be named bad_array_size?=20
> The description talks about size and containers use size(). Only string h=
as length() AFAIK.
>=20
> An array is not a container. For arrays, the core language calls the numb=
er of elements the 'bound' (see [dcl.array]p1), so bad_array_bound would be=
more appropriate. However, the standard library (since C++11) already has =
a std::bad_array_new_length exception, and consistency with that seems more=
important, so std::bad_array_length is the right name. The standard librar=
y also has std::extent, std::remove_extent, and std::remove_all_extents, so=
it's not even self-consistent. It's too late to fix this mess. :(
Worst of all, the length of an array containing a C string is greater than =
that according to strlen of the contained string.
Still, it seems OK to me that
"extent" refers to a property of an array type, which exists separately fro=
m any object, and may not be zero, whereas
"length" refers to a property of a particular dynamic object, and
sizeof is an operator dealing strictly in bytes, applicable to types or obj=
ects including arrays but not contents of containers.
Anyway, I don't see bad_array_length in N3797 so presumably it's been pushe=
d to the dynamic arrays TR.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_7640E05C-C025-4410-8AFF-D5034260C7CF
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Feb 6=
, 2014, at 2:02 AM, Richard Smith <<a href=3D"mailto:richard@metafoo.co.=
uk">richard@metafoo.co.uk</a>> wrote:</div><br class=3D"Apple-interchang=
e-newline"><blockquote type=3D"cite"><div dir=3D"ltr"><div class=3D"gmail_e=
xtra"><div class=3D"gmail_quote">On Wed, Feb 5, 2014 at 3:09 AM, Olaf van d=
er Spek <span dir=3D"ltr"><<a href=3D"mailto:olafvdspek@gmail.com" targe=
t=3D"_blank">olafvdspek@gmail.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex"><div dir=3D"ltr"><span style=3D"font-size: inherit; font-f=
amily: 'Times New Roman';">> The class </span><code style=3D"">bad_=
array_length</code><span style=3D"font-size: inherit; font-family: 'Times N=
ew Roman';"> defines the type of objects thrown as exceptions by the i=
mplementation to report an attempt to allocate an array of runtime bound wi=
th a size less than or equal to zero or greater than an implementation-defi=
ned limit (8.3.4 dcl.array).</span><br>
<div><span style=3D"font-size: inherit; font-family: 'Times New Roman';"><b=
r></span></div><div><span style=3D"font-size: inherit; font-family: 'Times =
New Roman';">Shouldn't this be named bad_array_size? </span></div>
<div><span style=3D"font-size: inherit; font-family: 'Times New Roman';">Th=
e description talks about size and containers use size(). Only string has l=
ength() AFAIK.</span></div></div></blockquote><div><br></div><div>An array =
is not a container. For arrays, the core language calls the number of eleme=
nts the 'bound' (see [dcl.array]p1), so bad_array_bound would be more appro=
priate. However, the standard library (since C++11) already has a std::bad_=
array_new_length exception, and consistency with that seems more important,=
so std::bad_array_length is the right name. The standard library also has =
std::extent, std::remove_extent, and std::remove_all_extents, so it's not e=
ven self-consistent. It's too late to fix this mess. :(</div></div></div></=
div></blockquote><div><br></div><div>Worst of all, the length of an array c=
ontaining a C string is greater than that according to <font face=3D"Courie=
r">strlen</font> of the contained string.</div></div><br><div>Still, it see=
ms OK to me that</div><div><ul class=3D"MailOutline"><li>“extent&rdqu=
o; refers to a property of an array type, which exists separately from any =
object, and may not be zero, whereas</li><li>“length” refers to=
a property of a particular dynamic object, and</li><li><font face=3D"Couri=
er">sizeof</font> is an operator dealing strictly in bytes, applicable=
to types or objects including arrays but not contents of containers.</li><=
/ul></div><div><br></div><div>Anyway, I don’t see <font face=3D"Couri=
er">bad_array_length</font> in N3797 so presumably it’s been pushed t=
o the dynamic arrays TR.</div><div><br></div></body></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail=_7640E05C-C025-4410-8AFF-D5034260C7CF--
.