Topic: std::bad_alloc inheriting from std::runtime_error
Author: Curious <rmn100@gmail.com>
Date: Wed, 15 Feb 2017 17:10:15 -0800 (PST)
Raw View
------=_Part_10868_2091800659.1487207415279
Content-Type: multipart/alternative;
boundary="----=_Part_10869_81048922.1487207415279"
------=_Part_10869_81048922.1487207415279
Content-Type: text/plain; charset=UTF-8
Most operating system interfaces offer a way to fetch the exception
messages associated with a failed allocation. For example linux offers
this by setting the thread local errno to be representative of an error
message, which the user can then fetch through a call to strerror().
Shouldn't std::bad_alloc offer a convenient way for users to set such an
error string? The only way one would do this is to write a class that
inherits from std::bad_alloc and then either override the what() member
function or write a string constructor like std::runtime_error.
Why not just make std::bad_alloc inherit from std::runtime_error so that it
too allows users to set an error string?
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/87189f18-9f75-4d9e-a100-9692dc9607b4%40isocpp.org.
------=_Part_10869_81048922.1487207415279
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Most operating system interfaces offer a way to fetch the =
exception messages associated with a failed allocation. =C2=A0For example l=
inux offers this by setting the thread local=C2=A0<font face=3D"courier new=
, monospace">errno</font>=C2=A0to be representative of an error message, wh=
ich the user can then fetch through a call to=C2=A0<font face=3D"courier ne=
w, monospace">strerror()</font>. =C2=A0Shouldn't=C2=A0<font face=3D"cou=
rier new, monospace">std::bad_alloc</font>=C2=A0offer a convenient way for =
users to set such an error string? =C2=A0The only way one would do this is =
to write a class that inherits from=C2=A0<font face=3D"courier new, monospa=
ce">std::bad_alloc</font>=C2=A0and then either override the=C2=A0<font face=
=3D"courier new, monospace">what()</font>=C2=A0member function or write a s=
tring constructor like=C2=A0<font face=3D"courier new, monospace">std::runt=
ime_error</font>. =C2=A0<div><br></div><div>Why not just make=C2=A0<font fa=
ce=3D"courier new, monospace">std::bad_alloc</font>=C2=A0inherit from=C2=A0=
<font face=3D"courier new, monospace">std::runtime_error</font><font face=
=3D"arial, sans-serif"> so that it too allows users to set an error string?=
</font></div></div>
<p></p>
-- <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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/87189f18-9f75-4d9e-a100-9692dc9607b4%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/87189f18-9f75-4d9e-a100-9692dc9607b4=
%40isocpp.org</a>.<br />
------=_Part_10869_81048922.1487207415279--
------=_Part_10868_2091800659.1487207415279--
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Wed, 15 Feb 2017 20:30:17 -0500
Raw View
<html><head></head><body lang=3D"en-US" style=3D"background-color: rgb(255,=
255, 255); line-height: initial;"> =
<div style=3D"width: 100%; fo=
nt-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif=
; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, =
255, 255);">Changing the base class of bad_alloc probably break ABI and pro=
bably also breaks code somewhere. </div><div style=3D"width: 100%; fon=
t-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif;=
color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 2=
55, 255);"><br></div><div style=3D"width: 100%; font-size: initial; font-fa=
mily: Calibri, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125)=
; text-align: initial; background-color: rgb(255, 255, 255);">Having bad_al=
loc take a string probably means an allocation, which could fail, =E2=80=8E=
rowing bad_alloc...</div> =
=
<div style=3D"width: 100%; font-size: initial; font-family: Calibri=
, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text-align:=
initial; background-color: rgb(255, 255, 255);"><br style=3D"display:initi=
al"></div> =
=
<div style=3D"font-s=
ize: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; co=
lor: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255,=
255);">Sent from my BlackBerry portable Babbage&n=
bsp;Device</div> =
=
<table width=3D"100%" style=3D"=
background-color:white;border-spacing:0px;"> <tbody><tr><td colspan=3D"2" s=
tyle=3D"font-size: initial; text-align: initial; background-color: rgb(255,=
255, 255);"> <div style=3D"border-style: solid n=
one none; border-top-color: rgb(181, 196, 223); border-top-width: 1pt; padd=
ing: 3pt 0in 0in; font-family: Tahoma, 'BB Alpha Sans', 'Slate Pro'; font-s=
ize: 10pt;"> <div><b>From: </b>Curious</div><div><b>Sent: </b>Wednesday, F=
ebruary 15, 2017 8:10 PM</div><div><b>To: </b>ISO C++ Standard - Future Pro=
posals</div><div><b>Reply To: </b>std-proposals@isocpp.org</div><div><b>Sub=
ject: </b>[std-proposals] std::bad_alloc inheriting from std::runtime_error=
</div></div></td></tr></tbody></table><div style=3D"border-style: solid non=
e none; border-top-color: rgb(186, 188, 209); border-top-width: 1pt; font-s=
ize: initial; text-align: initial; background-color: rgb(255, 255, 255);"><=
/div><br><div id=3D"_originalContent" style=3D""><div dir=3D"ltr">Most oper=
ating system interfaces offer a way to fetch the exception messages associa=
ted with a failed allocation. For example linux offers this by settin=
g the thread local <font face=3D"courier new, monospace">errno</font>&=
nbsp;to be representative of an error message, which the user can then fetc=
h through a call to <font face=3D"courier new, monospace">strerror()</=
font>. Shouldn't <font face=3D"courier new, monospace">std::bad_=
alloc</font> offer a convenient way for users to set such an error str=
ing? The only way one would do this is to write a class that inherits=
from <font face=3D"courier new, monospace">std::bad_alloc</font> =
;and then either override the <font face=3D"courier new, monospace">wh=
at()</font> member function or write a string constructor like <f=
ont face=3D"courier new, monospace">std::runtime_error</font>. <div><=
br></div><div>Why not just make <font face=3D"courier new, monospace">=
std::bad_alloc</font> inherit from <font face=3D"courier new, mon=
ospace">std::runtime_error</font><font face=3D"arial, sans-serif"> so that =
it too allows users to set an error string?</font></div></div>
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/87189f18-9f75-4d9e-a100-9692dc9607b4%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/87189f18-9f75-4d9e-a100-9692dc96=
07b4%40isocpp.org</a>.<br>
<br><!--end of _originalContent --></div></body></html>
<p></p>
-- <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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/20170216013017.4902991.17081.24897%40=
gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com=
/a/isocpp.org/d/msgid/std-proposals/20170216013017.4902991.17081.24897%40gm=
ail.com</a>.<br />
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Wed, 15 Feb 2017 17:33:30 -0800 (PST)
Raw View
------=_Part_10934_278029959.1487208810914
Content-Type: multipart/alternative;
boundary="----=_Part_10935_1876034781.1487208810914"
------=_Part_10935_1876034781.1487208810914
Content-Type: text/plain; charset=UTF-8
On Wednesday, February 15, 2017 at 8:10:15 PM UTC-5, Curious wrote:
>
> Most operating system interfaces offer a way to fetch the exception
> messages associated with a failed allocation. For example linux offers
> this by setting the thread local errno to be representative of an error
> message, which the user can then fetch through a call to strerror().
> Shouldn't std::bad_alloc offer a convenient way for users to set such an
> error string? The only way one would do this is to write a class that
> inherits from std::bad_alloc and then either override the what() member
> function or write a string constructor like std::runtime_error.
>
> Why not just make std::bad_alloc inherit from std::runtime_error so that
> it too allows users to set an error string?
>
How do you suppose `runtime_error` provides the ability to store a message
of arbitrary length? It does so by allocating memory. So if `bad_alloc`
inherits from `runtime_error`, it would potentially allocate memory. So
your error for allocating memory needs to allocate memory in order to be
constructed.
I see a flaw in this plan.
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/60e10c71-d2e1-4731-970f-0afaf407ce58%40isocpp.org.
------=_Part_10935_1876034781.1487208810914
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Wednesday, February 15, 2017 at 8:10:15 PM UTC-5, Curio=
us wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: =
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Most=
operating system interfaces offer a way to fetch the exception messages as=
sociated with a failed allocation. =C2=A0For example linux offers this by s=
etting the thread local=C2=A0<font face=3D"courier new, monospace">errno</f=
ont>=C2=A0to be representative of an error message, which the user can then=
fetch through a call to=C2=A0<font face=3D"courier new, monospace">strerro=
r()</font>. =C2=A0Shouldn't=C2=A0<font face=3D"courier new, monospace">=
std::bad_alloc</font>=C2=A0<wbr>offer a convenient way for users to set suc=
h an error string? =C2=A0The only way one would do this is to write a class=
that inherits from=C2=A0<font face=3D"courier new, monospace">std::bad_all=
oc</font>=C2=A0and then either override the=C2=A0<font face=3D"courier new,=
monospace">what()</font>=C2=A0member function or write a string constructo=
r like=C2=A0<font face=3D"courier new, monospace">std::runtime_error</font>=
.. =C2=A0<div><br></div><div>Why not just make=C2=A0<font face=3D"courier ne=
w, monospace">std::bad_alloc</font>=C2=A0inherit from=C2=A0<font face=3D"co=
urier new, monospace">std::runtime_error</font><font face=3D"arial, sans-se=
rif"> so that it too allows users to set an error string?</font></div></div=
></blockquote><div><br>How do you suppose `runtime_error` provides the abil=
ity to store a message of arbitrary length? It does so by allocating memory=
.. So if `bad_alloc` inherits from `runtime_error`, it would potentially all=
ocate memory. So your error for allocating memory needs to allocate memory =
in order to be constructed.<br><br>I see a flaw in this plan.<br></div></di=
v>
<p></p>
-- <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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/60e10c71-d2e1-4731-970f-0afaf407ce58%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/60e10c71-d2e1-4731-970f-0afaf407ce58=
%40isocpp.org</a>.<br />
------=_Part_10935_1876034781.1487208810914--
------=_Part_10934_278029959.1487208810914--
.
Author: rmn100@gmail.com
Date: Wed, 15 Feb 2017 18:04:25 -0800 (PST)
Raw View
------=_Part_1568_1925962573.1487210665218
Content-Type: multipart/alternative;
boundary="----=_Part_1569_1430253647.1487210665218"
------=_Part_1569_1430253647.1487210665218
Content-Type: text/plain; charset=UTF-8
I didn't read the details for runtime_error closely enough, I saw a c
string constructor and I assumed that it just stored the pointer somewhere
to avoid throwing. But is it not possible to just store a reference to a
string as a data variable?
On Wednesday, 15 February 2017 20:33:31 UTC-5, Nicol Bolas wrote:
>
> On Wednesday, February 15, 2017 at 8:10:15 PM UTC-5, Curious wrote:
>>
>> Most operating system interfaces offer a way to fetch the exception
>> messages associated with a failed allocation. For example linux offers
>> this by setting the thread local errno to be representative of an error
>> message, which the user can then fetch through a call to strerror().
>> Shouldn't std::bad_alloc offer a convenient way for users to set such
>> an error string? The only way one would do this is to write a class that
>> inherits from std::bad_alloc and then either override the what() member
>> function or write a string constructor like std::runtime_error.
>>
>> Why not just make std::bad_alloc inherit from std::runtime_error so that
>> it too allows users to set an error string?
>>
>
> How do you suppose `runtime_error` provides the ability to store a message
> of arbitrary length? It does so by allocating memory. So if `bad_alloc`
> inherits from `runtime_error`, it would potentially allocate memory. So
> your error for allocating memory needs to allocate memory in order to be
> constructed.
>
> I see a flaw in this plan.
>
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/14e84aac-d4a6-4a07-8b47-be266da7873c%40isocpp.org.
------=_Part_1569_1430253647.1487210665218
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I didn't read the details for <font face=3D"courier ne=
w, monospace">runtime_error</font> closely enough, I saw a c string constru=
ctor and I assumed that it just stored the pointer somewhere to avoid throw=
ing. =C2=A0But is it not possible to just store a reference to a string as =
a data variable? =C2=A0<br><br>On Wednesday, 15 February 2017 20:33:31 UTC-=
5, Nicol Bolas wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;=
margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">On Wednesday, February 15, 2017 at 8:10:15 PM UTC-5, Curious wrote=
:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bord=
er-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Most operating sy=
stem interfaces offer a way to fetch the exception messages associated with=
a failed allocation. =C2=A0For example linux offers this by setting the th=
read local=C2=A0<font face=3D"courier new, monospace">errno</font>=C2=A0to =
be representative of an error message, which the user can then fetch throug=
h a call to=C2=A0<font face=3D"courier new, monospace">strerror()</font>. =
=C2=A0Shouldn't=C2=A0<font face=3D"courier new, monospace">std::bad_all=
oc</font>=C2=A0<wbr>offer a convenient way for users to set such an error s=
tring? =C2=A0The only way one would do this is to write a class that inheri=
ts from=C2=A0<font face=3D"courier new, monospace">std::bad_alloc</font>=C2=
=A0and then either override the=C2=A0<font face=3D"courier new, monospace">=
what()</font>=C2=A0member function or write a string constructor like=C2=A0=
<font face=3D"courier new, monospace">std::runtime_error</font>. =C2=A0<div=
><br></div><div>Why not just make=C2=A0<font face=3D"courier new, monospace=
">std::bad_alloc</font>=C2=A0inherit from=C2=A0<font face=3D"courier new, m=
onospace">std::runtime_error</font><font face=3D"arial, sans-serif"> so tha=
t it too allows users to set an error string?</font></div></div></blockquot=
e><div><br>How do you suppose `runtime_error` provides the ability to store=
a message of arbitrary length? It does so by allocating memory. So if `bad=
_alloc` inherits from `runtime_error`, it would potentially allocate memory=
.. So your error for allocating memory needs to allocate memory in order to =
be constructed.<br><br>I see a flaw in this plan.<br></div></div></blockquo=
te></div>
<p></p>
-- <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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/14e84aac-d4a6-4a07-8b47-be266da7873c%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/14e84aac-d4a6-4a07-8b47-be266da7873c=
%40isocpp.org</a>.<br />
------=_Part_1569_1430253647.1487210665218--
------=_Part_1568_1925962573.1487210665218--
.
Author: David Krauss <potswa@gmail.com>
Date: Thu, 16 Feb 2017 10:29:12 +0800
Raw View
--Apple-Mail=_E198D0C3-7679-470C-99AB-D14100C90F62
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2017=E2=80=9302=E2=80=9316, at 9:33 AM, Nicol Bolas <jmckesson@gmail.c=
om <mailto:jmckesson@gmail.com>> wrote:
>=20
> How do you suppose `runtime_error` provides the ability to store a messag=
e of arbitrary length? It does so by allocating memory. So if `bad_alloc` i=
nherits from `runtime_error`, it would potentially allocate memory. So your=
error for allocating memory needs to allocate memory in order to be constr=
ucted.
>=20
> I see a flaw in this plan.
bad_alloc could take a char const* to static storage, specifically not supp=
orting dynamically generated strings, unlike runtime_error and like strerro=
r.
Solvable, just not very C++-like.
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/C4180CC9-3C3A-41A4-A3C8-3649EE9480C4%40gmail.com=
..
--Apple-Mail=_E198D0C3-7679-470C-99AB-D14100C90F62
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"><meta http-equiv=3D"Content-Type" content=3D"text/html charset=3D=
utf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: spac=
e; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><div c=
lass=3D""><blockquote type=3D"cite" class=3D""><div class=3D"">On 2017=E2=
=80=9302=E2=80=9316, at 9:33 AM, Nicol Bolas <<a href=3D"mailto:jmckesso=
n@gmail.com" class=3D"">jmckesson@gmail.com</a>> wrote:</div><br class=
=3D"Apple-interchange-newline"><div class=3D""><div dir=3D"ltr" class=3D"">=
<div class=3D"">How do you suppose `runtime_error` provides the ability to =
store a message of arbitrary length? It does so by allocating memory. So if=
`bad_alloc` inherits from `runtime_error`, it would potentially allocate m=
emory. So your error for allocating memory needs to allocate memory in orde=
r to be constructed.<br class=3D""><br class=3D"">I see a flaw in this plan=
..<br class=3D""></div></div></div></blockquote><div class=3D""><br class=3D=
""></div><font face=3D"Courier" class=3D"">bad_alloc</font> could take a <f=
ont face=3D"Courier" class=3D"">char const*</font> to static storage, =
specifically <i class=3D"">not</i> supporting dynamically generated st=
rings, unlike <font face=3D"Courier" class=3D"">runtime_error</font> and li=
ke <font face=3D"Courier" class=3D"">strerror</font>.</div><div class=3D"">=
<br class=3D""></div><div class=3D"">Solvable, just not very C++-like.</div=
><div class=3D""><br class=3D""></div></body></html>
<p></p>
-- <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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/C4180CC9-3C3A-41A4-A3C8-3649EE9480C4%=
40gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/C4180CC9-3C3A-41A4-A3C8-3649EE9480C4%=
40gmail.com</a>.<br />
--Apple-Mail=_E198D0C3-7679-470C-99AB-D14100C90F62--
.
Author: Curious <rmn100@gmail.com>
Date: Wed, 15 Feb 2017 18:34:48 -0800 (PST)
Raw View
------=_Part_2665_555711651.1487212488896
Content-Type: multipart/alternative;
boundary="----=_Part_2666_752886381.1487212488896"
------=_Part_2666_752886381.1487212488896
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
What about an error integer that can be used in conjunction with=20
std::strerror() to get an error message, since that is the scheme of things=
=20
on most systems
On Wednesday, 15 February 2017 21:29:40 UTC-5, David Krauss wrote:
>
>
> On 2017=E2=80=9302=E2=80=9316, at 9:33 AM, Nicol Bolas <jmck...@gmail.com=
<javascript:>>=20
> wrote:
>
> How do you suppose `runtime_error` provides the ability to store a messag=
e=20
> of arbitrary length? It does so by allocating memory. So if `bad_alloc`=
=20
> inherits from `runtime_error`, it would potentially allocate memory. So=
=20
> your error for allocating memory needs to allocate memory in order to be=
=20
> constructed.
>
> I see a flaw in this plan.
>
>
> bad_alloc could take a char const* to static storage, specifically *not* =
supporting=20
> dynamically generated strings, unlike runtime_error and like strerror.
>
> Solvable, just not very C++-like.
>
>
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/a8a5845f-91d1-44a4-ae63-f430a736adb0%40isocpp.or=
g.
------=_Part_2666_752886381.1487212488896
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">What about an error integer that can be used in conjunctio=
n with <font face=3D"courier new, monospace">std::strerror()</font> to get =
an error message, since that is the scheme of things on most systems<br><br=
>On Wednesday, 15 February 2017 21:29:40 UTC-5, David Krauss wrote:<blockq=
uote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-lef=
t: 1px #ccc solid;padding-left: 1ex;"><div style=3D"word-wrap:break-word"><=
br><div><blockquote type=3D"cite"><div>On 2017=E2=80=9302=E2=80=9316, at 9:=
33 AM, Nicol Bolas <<a href=3D"javascript:" target=3D"_blank" gdf-obfusc=
ated-mailto=3D"X7VUn_pHBQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#=
39;javascript:';return true;" onclick=3D"this.href=3D'javascript:&#=
39;;return true;">jmck...@gmail.com</a>> wrote:</div><br><div><div dir=
=3D"ltr"><div>How do you suppose `runtime_error` provides the ability to st=
ore a message of arbitrary length? It does so by allocating memory. So if `=
bad_alloc` inherits from `runtime_error`, it would potentially allocate mem=
ory. So your error for allocating memory needs to allocate memory in order =
to be constructed.<br><br>I see a flaw in this plan.<br></div></div></div><=
/blockquote><div><br></div><font face=3D"Courier">bad_alloc</font> could ta=
ke a <font face=3D"Courier">char const*</font>=C2=A0to static storage, spec=
ifically <i>not</i>=C2=A0supporting dynamically generated strings, unlike <=
font face=3D"Courier">runtime_error</font> and like <font face=3D"Courier">=
strerror</font>.</div><div><br></div><div>Solvable, just not very C++-like.=
</div><div><br></div></div></blockquote></div>
<p></p>
-- <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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/a8a5845f-91d1-44a4-ae63-f430a736adb0%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a8a5845f-91d1-44a4-ae63-f430a736adb0=
%40isocpp.org</a>.<br />
------=_Part_2666_752886381.1487212488896--
------=_Part_2665_555711651.1487212488896--
.
Author: rmn100@gmail.com
Date: Wed, 15 Feb 2017 18:35:47 -0800 (PST)
Raw View
------=_Part_2512_366729351.1487212547713
Content-Type: multipart/alternative;
boundary="----=_Part_2513_1032257638.1487212547713"
------=_Part_2513_1032257638.1487212547713
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
It could store a std::string_view object? That sounds very C++ like=20
On Wednesday, 15 February 2017 21:29:40 UTC-5, David Krauss wrote:
>
>
> On 2017=E2=80=9302=E2=80=9316, at 9:33 AM, Nicol Bolas <jmck...@gmail.com=
<javascript:>>=20
> wrote:
>
> How do you suppose `runtime_error` provides the ability to store a messag=
e=20
> of arbitrary length? It does so by allocating memory. So if `bad_alloc`=
=20
> inherits from `runtime_error`, it would potentially allocate memory. So=
=20
> your error for allocating memory needs to allocate memory in order to be=
=20
> constructed.
>
> I see a flaw in this plan.
>
>
> bad_alloc could take a char const* to static storage, specifically *not* =
supporting=20
> dynamically generated strings, unlike runtime_error and like strerror.
>
> Solvable, just not very C++-like.
>
>
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/08d78456-dad1-4fd3-869e-57e88bade7ef%40isocpp.or=
g.
------=_Part_2513_1032257638.1487212547713
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">It could store a <font face=3D"courier new, monospace">std=
::string_view</font> object? =C2=A0That sounds very C++ like=C2=A0<br><br>O=
n Wednesday, 15 February 2017 21:29:40 UTC-5, David Krauss wrote:<blockquo=
te class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left:=
1px #ccc solid;padding-left: 1ex;"><div style=3D"word-wrap:break-word"><br=
><div><blockquote type=3D"cite"><div>On 2017=E2=80=9302=E2=80=9316, at 9:33=
AM, Nicol Bolas <<a href=3D"javascript:" target=3D"_blank" gdf-obfuscat=
ed-mailto=3D"X7VUn_pHBQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'=
;javascript:';return true;" onclick=3D"this.href=3D'javascript:'=
;;return true;">jmck...@gmail.com</a>> wrote:</div><br><div><div dir=3D"=
ltr"><div>How do you suppose `runtime_error` provides the ability to store =
a message of arbitrary length? It does so by allocating memory. So if `bad_=
alloc` inherits from `runtime_error`, it would potentially allocate memory.=
So your error for allocating memory needs to allocate memory in order to b=
e constructed.<br><br>I see a flaw in this plan.<br></div></div></div></blo=
ckquote><div><br></div><font face=3D"Courier">bad_alloc</font> could take a=
<font face=3D"Courier">char const*</font>=C2=A0to static storage, specific=
ally <i>not</i>=C2=A0supporting dynamically generated strings, unlike <font=
face=3D"Courier">runtime_error</font> and like <font face=3D"Courier">stre=
rror</font>.</div><div><br></div><div>Solvable, just not very C++-like.</di=
v><div><br></div></div></blockquote></div>
<p></p>
-- <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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/08d78456-dad1-4fd3-869e-57e88bade7ef%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/08d78456-dad1-4fd3-869e-57e88bade7ef=
%40isocpp.org</a>.<br />
------=_Part_2513_1032257638.1487212547713--
------=_Part_2512_366729351.1487212547713--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Wed, 15 Feb 2017 18:36:55 -0800
Raw View
On quarta-feira, 15 de fevereiro de 2017 17:10:15 PST Curious wrote:
> Most operating system interfaces offer a way to fetch the exception
> messages associated with a failed allocation. For example linux offers
> this by setting the thread local errno to be representative of an error
> message, which the user can then fetch through a call to strerror().
The only possible error for malloc(3) is ENOMEM.
The only errors for mmap(2) and brk(2) that do not imply a bug in the
implementation is ENOMEM.
So what error message could we get from bad_alloc that is not "Out of memory"?
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/3228626.8TiUKsI9a1%40tjmaciei-mobl1.
.
Author: rmn100@gmail.com
Date: Wed, 15 Feb 2017 18:54:30 -0800 (PST)
Raw View
------=_Part_1547_435285454.1487213670878
Content-Type: multipart/alternative;
boundary="----=_Part_1548_343829619.1487213670878"
------=_Part_1548_343829619.1487213670878
Content-Type: text/plain; charset=UTF-8
The way I was imagining this was that the error type can be used to make a
very elaborate allocator. One that can be used at a very low level like
malloc as well as at a high level doing things like allocating shared
memory either from the network some other medium like files.
On Wednesday, 15 February 2017 21:37:03 UTC-5, Thiago Macieira wrote:
>
> On quarta-feira, 15 de fevereiro de 2017 17:10:15 PST Curious wrote:
> > Most operating system interfaces offer a way to fetch the exception
> > messages associated with a failed allocation. For example linux offers
> > this by setting the thread local errno to be representative of an error
> > message, which the user can then fetch through a call to strerror().
>
> The only possible error for malloc(3) is ENOMEM.
>
> The only errors for mmap(2) and brk(2) that do not imply a bug in the
> implementation is ENOMEM.
>
> So what error message could we get from bad_alloc that is not "Out of
> memory"?
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel Open Source Technology Center
>
>
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/84e6ff0d-994f-46e5-a352-53c73b1b4a46%40isocpp.org.
------=_Part_1548_343829619.1487213670878
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The way I was imagining this was that the error type can b=
e used to make a very elaborate allocator. =C2=A0One that can be used at a =
very low level like malloc as well as at a high level doing things like all=
ocating shared memory either from the network some other medium like files.=
=C2=A0<br><br>On Wednesday, 15 February 2017 21:37:03 UTC-5, Thiago Maciei=
ra wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:=
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On quarta-feira, 15 =
de fevereiro de 2017 17:10:15 PST Curious wrote:
<br>> Most operating system interfaces offer a way to fetch the exceptio=
n
<br>> messages associated with a failed allocation. =C2=A0For example li=
nux offers
<br>> this by setting the thread local errno to be representative of an =
error
<br>> message, which the user can then fetch through a call to strerror(=
).
<br>
<br>The only possible error for malloc(3) is ENOMEM.
<br>
<br>The only errors for mmap(2) and brk(2) that do not imply a bug in the=
=20
<br>implementation is ENOMEM.
<br>
<br>So what error message could we get from bad_alloc that is not "Out=
of memory"?
<br>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.goo=
gle.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x3dD\x26sntz\x3d1\x26usg\=
x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return true;" onclick=3D"this.hr=
ef=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x=
3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return t=
rue;">macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" target=3D"=
_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.google.=
com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH=
GRJdo5_JYG1DowztwAHAKs80XSA';return true;" onclick=3D"this.href=3D'=
http://www.google.com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1=
\x26usg\x3dAFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';return true;">kde.org</a=
>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>
<br></blockquote></div>
<p></p>
-- <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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/84e6ff0d-994f-46e5-a352-53c73b1b4a46%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/84e6ff0d-994f-46e5-a352-53c73b1b4a46=
%40isocpp.org</a>.<br />
------=_Part_1548_343829619.1487213670878--
------=_Part_1547_435285454.1487213670878--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Wed, 15 Feb 2017 19:40:19 -0800
Raw View
Em quarta-feira, 15 de fevereiro de 2017, =C3=A0s 18:54:30 PST, rmn100@gmai=
l.com=20
escreveu:
> The way I was imagining this was that the error type can be used to make =
a
> very elaborate allocator. One that can be used at a very low level like
> malloc as well as at a high level doing things like allocating shared
> memory either from the network some other medium like files.
You can create MyLib::bad_alloc that derives from std::bad_alloc and includ=
es=20
more information. But the regular memory allocation can only fail for one=
=20
reason and therefore the fact that the exception was std::bad_alloc is=20
sufficient.
--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/2067979.DhMrO0zR8f%40tjmaciei-mobl1.
.
Author: David Krauss <potswa@gmail.com>
Date: Thu, 16 Feb 2017 11:40:46 +0800
Raw View
--Apple-Mail=_94B857AC-FA55-4699-B6EA-1FAE6D94D943
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
A string_view pointing to dynamic storage would be tricky, since an excepti=
on object (or its copies) can live indefinitely through exception_ptr. The =
owner would have no way to know to free the string, so it would either leak=
or dangle.
Shared ownership would solve that problem, and as it happens runtime_error =
implements just that, to achieve noexcept copyability. The idiom is to cons=
truct the exception object ahead of time so it=E2=80=99s ready to throw if =
necessary.
So=E2=80=A6 that brings us back to the original suggestion, full circle.
> On 2017=E2=80=9302=E2=80=9316, at 10:35 AM, rmn100@gmail.com wrote:
>=20
> It could store a std::string_view object? That sounds very C++ like=20
>=20
> On Wednesday, 15 February 2017 21:29:40 UTC-5, David Krauss wrote:
>=20
> bad_alloc could take a char const* to static storage, specifically not su=
pporting dynamically generated strings, unlike runtime_error and like strer=
ror.
>=20
> Solvable, just not very C++-like.
>=20
>=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=
email to std-proposals+unsubscribe@isocpp.org <mailto:std-proposals+unsubs=
cribe@isocpp.org>.
> To post to this group, send email to std-proposals@isocpp.org <mailto:std=
-proposals@isocpp.org>.
> To view this discussion on the web visit https://groups.google.com/a/isoc=
pp.org/d/msgid/std-proposals/08d78456-dad1-4fd3-869e-57e88bade7ef%40isocpp.=
org <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/08d78456-=
dad1-4fd3-869e-57e88bade7ef%40isocpp.org?utm_medium=3Demail&utm_source=3Dfo=
oter>.
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/45F1F5A1-4C01-4803-A482-A128BCC3DC17%40gmail.com=
..
--Apple-Mail=_94B857AC-FA55-4699-B6EA-1FAE6D94D943
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><div class=3D"">A =
<font face=3D"Courier" class=3D"">string_view</font> pointing to dynamic st=
orage would be tricky, since an exception object (or its copies) can live i=
ndefinitely through <font face=3D"Courier" class=3D"">exception_ptr</font>.=
The owner would have no way to know to free the string, so it would either=
leak or dangle.</div><div class=3D""><br class=3D""></div><div class=3D"">=
Shared ownership would solve that problem, and as it happens <font face=3D"=
Courier" class=3D"">runtime_error</font> implements just that, to achieve <=
font face=3D"Courier" class=3D"">noexcept</font> copyability. The idiom is =
to construct the exception object ahead of time so it=E2=80=99s ready to th=
row if necessary.</div><div class=3D""><br class=3D""></div><div class=3D""=
>So=E2=80=A6 that brings us back to the original suggestion, full circle.</=
div><div class=3D""><br class=3D""></div><br class=3D""><div><blockquote ty=
pe=3D"cite" class=3D""><div class=3D"">On 2017=E2=80=9302=E2=80=9316, at 10=
:35 AM, <a href=3D"mailto:rmn100@gmail.com" class=3D"">rmn100@gmail.com</a>=
wrote:</div><br class=3D"Apple-interchange-newline"><div class=3D""><div d=
ir=3D"ltr" class=3D"">It could store a <font face=3D"courier new, monospace=
" class=3D"">std::string_view</font> object? That sounds very C++ lik=
e <br class=3D""><br class=3D"">On Wednesday, 15 February 2017 21:29:4=
0 UTC-5, David Krauss wrote:<blockquote class=3D"gmail_quote" style=3D"mar=
gin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><=
div style=3D"word-wrap:break-word" class=3D""><div class=3D""><div class=3D=
""><br class=3D""></div><font face=3D"Courier" class=3D"">bad_alloc</font> =
could take a <font face=3D"Courier" class=3D"">char const*</font> to s=
tatic storage, specifically <i class=3D"">not</i> supporting dynamical=
ly generated strings, unlike <font face=3D"Courier" class=3D"">runtime_erro=
r</font> and like <font face=3D"Courier" class=3D"">strerror</font>.</div><=
div class=3D""><br class=3D""></div><div class=3D"">Solvable, just not very=
C++-like.</div><div class=3D""><br class=3D""></div></div></blockquote></d=
iv><div class=3D""><br class=3D"webkit-block-placeholder"></div>
-- <br class=3D"">
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br class=3D"">
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" class=3D"">=
std-proposals+unsubscribe@isocpp.org</a>.<br class=3D"">
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" class=3D"">std-proposals@isocpp.org</a>.<br class=3D"">
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/08d78456-dad1-4fd3-869e-57e88bade7ef%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" class=3D"">https:/=
/groups.google.com/a/isocpp.org/d/msgid/std-proposals/08d78456-dad1-4fd3-86=
9e-57e88bade7ef%40isocpp.org</a>.<br class=3D"">
</div></blockquote></div><br class=3D""></body></html>
<p></p>
-- <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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/45F1F5A1-4C01-4803-A482-A128BCC3DC17%=
40gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/45F1F5A1-4C01-4803-A482-A128BCC3DC17%=
40gmail.com</a>.<br />
--Apple-Mail=_94B857AC-FA55-4699-B6EA-1FAE6D94D943--
.
Author: Jens Maurer <Jens.Maurer@gmx.net>
Date: Thu, 16 Feb 2017 21:44:46 +0100
Raw View
On 02/16/2017 02:10 AM, Curious wrote:
> Most operating system interfaces offer a way to fetch the exception messa=
ges associated with a failed allocation. For example linux offers this by =
setting the thread local errno to be representative of an error message, wh=
ich the user can then fetch through a call to strerror(). Shouldn't std::b=
ad_alloc offer a convenient way for users to set such an error string? The=
only way one would do this is to write a class that inherits from std::bad=
_alloc and then either override the what() member function or write a strin=
g constructor like std::runtime_error. =20
What errno value do you expect from a std::bad_alloc other than ENOMEM?
Jens
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/58A60F3E.7080205%40gmx.net.
.
Author: Andrey Semashev <andrey.semashev@gmail.com>
Date: Fri, 17 Feb 2017 00:18:23 +0300
Raw View
On 02/16/17 05:54, rmn100@gmail.com wrote:
> The way I was imagining this was that the error type can be used to make
> a very elaborate allocator. One that can be used at a very low level
> like malloc as well as at a high level doing things like allocating
> shared memory either from the network some other medium like files.
Such allocator could throw its own exception type that derives from
bad_alloc.
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/103ff40c-486f-1ea7-48ac-4c6502ac63e7%40gmail.com.
.