Topic: destructor overloading: unwinding destructor
Author: "dgutson ." <danielgutson@gmail.com>
Date: Sun, 2 Jul 2017 22:49:59 -0300
Raw View
--001a114bdc581efe7c05535ffc7a
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Despite the fact that std::uncaught_exceptions has been approved, I wanted
to survey a potential acceptance of an alternative: the ability to overload
(and potentially =3Ddelete) a second version of destructors: one that accep=
ts
an unsigned integer representing the number of uncaught exception, that is,
differentiate the destructor called not during unwinding (the current
signature) and a destructor called when unwinding is ongoing.
If only ~T() is provided, then it would be a dual-intention destructor: it
will be called in both scenarios (during unwinding and not during
unwinding).
If only ~T(unsigned int) is provided, then it would be also a
dual-intention destructor, called with 0 when there is not unwinding in
progress, and greater than zero with the number of exceptions.
If both ~T() and ~T(unsigned int) are provided, then ~T() is called when no
unwinding, and ~T(usigned int) is called when unwinding with the argument
greater than zero.
Why? Because I found that all the times I had to use
std::uncaught_exception/s, the true/else parts of the if had nothing in
common, that is, the destructor had to do completely different stuff, so I
think that I could make sense to arrange the code in two semantic-separated
methods. It would not just be about avoiding a conditional. Inheritance
could also get fancy, though I did not elaborate about it yet.
Let me show you a real-life example: a DB Transaction RAII object:
Db::RAII_Transaction::~RAII_Transaction(){ if
(std::uncaught_exception()) { try {
rollback(); } catch(...) { //...
} } else if (doCommit) { try {
commit*(*);
} catch (...) { //... } }}
With my proposed addition, the code above would be arguably clearer as
follows:
Db::RAII_Transaction::~RAII_Transaction(){
if (doCommit)
{ try { commit*(*);
} catch (...) { //... } }}
Db::RAII_Transaction::~RAII_Transaction(unsigned int){
try { rollback(); } catch(...)
{ //...
} }}
Do you people agree this is enough motivation?
Thanks,
Daniel.
--=20
Who=E2=80=99s got the sweetest disposition?
One guess, that=E2=80=99s who?
Who=E2=80=99d never, ever start an argument?
Who never shows a bit of temperament?
Who's never wrong but always right?
Who'd never dream of starting a fight?
Who get stuck with all the bad luck?
--=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/CAFdMc-362Wu239Tf-q2qSkUu6GCYu1ekFT-GPSETjGuFT6O=
5%2Bg%40mail.gmail.com.
--001a114bdc581efe7c05535ffc7a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Despite the fact that std::uncaught_exceptions has been ap=
proved, I wanted to survey a potential acceptance of an alternative: the ab=
ility to overload (and potentially =3Ddelete) a second version of destructo=
rs: one that accepts an unsigned integer representing the number of uncaugh=
t exception, that is, differentiate the destructor called not during unwind=
ing (the current signature) and a destructor called when unwinding is ongoi=
ng.<div><br></div><div>If only ~T() is provided, then it would be a dual-in=
tention destructor: it will be called in both scenarios (during unwinding a=
nd not during unwinding).</div><div>If only ~T(unsigned int) is provided, t=
hen it would be also a dual-intention destructor, called with 0 when there =
is not unwinding in progress, and greater than zero with the number of exce=
ptions.</div><div>If both ~T() and ~T(unsigned int) are provided, then ~T()=
is called when no unwinding, and ~T(usigned int) is called when unwinding =
with the argument greater than zero.</div><div><br></div><div>Why? Because =
I found that all the times I had to use std::uncaught_exception/s, the true=
/else parts of the if had nothing in common, that is, the destructor had to=
do completely different stuff, so I think that I could make sense to arran=
ge the code in two semantic-separated methods. It would not just be about a=
voiding a conditional. Inheritance could also get fancy, though I did not e=
laborate about it yet.</div><div><br></div><div>Let me show you a real-life=
example: a DB Transaction RAII object:</div><div><br></div><div><pre style=
=3D"margin-top:0px;margin-bottom:0px;padding:0px;font-family:Consolas,Menlo=
,"Liberation Mono",Courier,monospace;font-size:12px;line-height:1=
..4;letter-spacing:0px;color:rgb(23,43,77)"><span class=3D"gmail-n">Db</span=
><span class=3D"gmail-o" style=3D"font-weight:700">::</span><span class=3D"=
gmail-n">RAII_Transaction</span><span class=3D"gmail-o" style=3D"font-weigh=
t:700">::~</span><span class=3D"gmail-n">RAII_Transaction</span><span class=
=3D"gmail-p">()</span>
<a name=3D"db_operations.cpp-164" style=3D"color:rgb(0,82,204)"></a><span c=
lass=3D"gmail-p">{</span>
<a name=3D"db_operations.cpp-165" style=3D"color:rgb(0,82,204)"></a> <sp=
an class=3D"gmail-k" style=3D"font-weight:700">if</span> <span class=3D"gma=
il-p">(</span><span class=3D"gmail-n">std</span><span class=3D"gmail-o" sty=
le=3D"font-weight:700">::</span><span class=3D"gmail-n">uncaught_exception<=
/span><span class=3D"gmail-p">())</span>
<a name=3D"db_operations.cpp-166" style=3D"color:rgb(0,82,204)"></a> <sp=
an class=3D"gmail-p">{</span>
<a name=3D"db_operations.cpp-167" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-k" style=3D"font-weight:700">try</span>
<a name=3D"db_operations.cpp-168" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-p">{</span>
<a name=3D"db_operations.cpp-169" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-n">rollback</span><span class=3D"gmail-p">();</sp=
an>
<a name=3D"db_operations.cpp-170" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-p">}</span>
<a name=3D"db_operations.cpp-171" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-k" style=3D"font-weight:700">catch</span><span class=
=3D"gmail-p">(...)</span>
<a name=3D"db_operations.cpp-172" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-p">{</span>
<a name=3D"db_operations.cpp-173" style=3D"color:rgb(0,82,204)"></a> =
//...</pre><pre style=3D"margin-top:0px;margin-bottom:0px;padding:0p=
x;font-family:Consolas,Menlo,"Liberation Mono",Courier,monospace;=
font-size:12px;line-height:1.4;letter-spacing:0px;color:rgb(23,43,77)"> =
<span class=3D"gmail-p">}</span>
<a name=3D"db_operations.cpp-175" style=3D"color:rgb(0,82,204)"></a> <sp=
an class=3D"gmail-p">}</span>
<a name=3D"db_operations.cpp-176" style=3D"color:rgb(0,82,204)"></a> <sp=
an class=3D"gmail-k" style=3D"font-weight:700">else</span> <span class=3D"g=
mail-k" style=3D"font-weight:700">if</span> <span class=3D"gmail-p">(do</sp=
an><span class=3D"gmail-n">Commit</span><span class=3D"gmail-p">)</span>
<a name=3D"db_operations.cpp-177" style=3D"color:rgb(0,82,204)"></a> <sp=
an class=3D"gmail-p">{</span>
<a name=3D"db_operations.cpp-178" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-k" style=3D"font-weight:700">try</span>
<a name=3D"db_operations.cpp-179" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-p">{</span>
<a name=3D"db_operations.cpp-180" style=3D"color:rgb(0,82,204)"></a> =
commit<b style=3D"letter-spacing:0px">(</b><span class=3D"gmail-p" sty=
le=3D"letter-spacing:0px">);</span><br><a name=3D"db_operations.cpp-185" st=
yle=3D"color:rgb(0,82,204)"></a> <span class=3D"gmail-p">}</span>
<a name=3D"db_operations.cpp-186" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-k" style=3D"font-weight:700">catch</span> <span class=
=3D"gmail-p">(...)</span>
<a name=3D"db_operations.cpp-187" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-p">{</span>
<a name=3D"db_operations.cpp-188" style=3D"color:rgb(0,82,204)"></a> =
//...
<a name=3D"db_operations.cpp-189" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-p">}</span>
<a name=3D"db_operations.cpp-190" style=3D"color:rgb(0,82,204)"></a> <sp=
an class=3D"gmail-p">}</span>
<a name=3D"db_operations.cpp-191" style=3D"color:rgb(0,82,204)"></a><span c=
lass=3D"gmail-p">}</span></pre></div><div><div><br></div><div><br></div><di=
v>With my proposed addition, the code above would be arguably clearer as fo=
llows:</div><div><br></div><div><div><pre style=3D"margin-top:0px;margin-bo=
ttom:0px;padding:0px;font-family:Consolas,Menlo,"Liberation Mono"=
,Courier,monospace;font-size:12px;line-height:1.4;letter-spacing:0px;color:=
rgb(23,43,77)"><span class=3D"gmail-n">Db</span><span class=3D"gmail-o" sty=
le=3D"font-weight:700">::</span><span class=3D"gmail-n">RAII_Transaction</s=
pan><span class=3D"gmail-o" style=3D"font-weight:700">::~</span><span class=
=3D"gmail-n">RAII_Transaction</span><span class=3D"gmail-p">()</span>
<a name=3D"db_operations.cpp-164" style=3D"color:rgb(0,82,204)"></a><span c=
lass=3D"gmail-p">{</span></pre><pre style=3D"margin-top:0px;margin-bottom:0=
px;padding:0px;font-family:Consolas,Menlo,"Liberation Mono",Couri=
er,monospace;font-size:12px;line-height:1.4;letter-spacing:0px;color:rgb(23=
,43,77)"> <span class=3D"gmail-k" style=3D"letter-spacing:0px;font-weigh=
t:700">if</span><span style=3D"letter-spacing:0px"> </span><span class=3D"g=
mail-p" style=3D"letter-spacing:0px">(do</span><span class=3D"gmail-n" styl=
e=3D"letter-spacing:0px">Commit</span><span class=3D"gmail-p" style=3D"lett=
er-spacing:0px">)</span>
</pre><pre style=3D"margin-top:0px;margin-bottom:0px;padding:0px;font-famil=
y:Consolas,Menlo,"Liberation Mono",Courier,monospace;font-size:12=
px;line-height:1.4;letter-spacing:0px;color:rgb(23,43,77)"><a name=3D"db_op=
erations.cpp-177" style=3D"color:rgb(0,82,204)"></a> <span class=3D"gmai=
l-p">{</span>
<a name=3D"db_operations.cpp-178" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-k" style=3D"font-weight:700">try</span>
<a name=3D"db_operations.cpp-179" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-p">{</span>
<a name=3D"db_operations.cpp-180" style=3D"color:rgb(0,82,204)"></a> =
commit<b style=3D"letter-spacing:0px">(</b><span class=3D"gmail-p" sty=
le=3D"letter-spacing:0px">);</span><br><a name=3D"db_operations.cpp-185" st=
yle=3D"color:rgb(0,82,204)"></a> <span class=3D"gmail-p">}</span>
<a name=3D"db_operations.cpp-186" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-k" style=3D"font-weight:700">catch</span> <span class=
=3D"gmail-p">(...)</span>
<a name=3D"db_operations.cpp-187" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-p">{</span>
<a name=3D"db_operations.cpp-188" style=3D"color:rgb(0,82,204)"></a> =
//...
<a name=3D"db_operations.cpp-189" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-p">}</span>
<a name=3D"db_operations.cpp-190" style=3D"color:rgb(0,82,204)"></a> <sp=
an class=3D"gmail-p">}</span>
<a name=3D"db_operations.cpp-191" style=3D"color:rgb(0,82,204)"></a><span c=
lass=3D"gmail-p">}</span></pre></div><div></div></div><div><br></div><div><=
div><pre style=3D"margin-top:0px;margin-bottom:0px;padding:0px;font-family:=
Consolas,Menlo,"Liberation Mono",Courier,monospace;font-size:12px=
;line-height:1.4;letter-spacing:0px;color:rgb(23,43,77)"><span class=3D"gma=
il-n">Db</span><span class=3D"gmail-o" style=3D"font-weight:700">::</span><=
span class=3D"gmail-n">RAII_Transaction</span><span class=3D"gmail-o" style=
=3D"font-weight:700">::~</span><span class=3D"gmail-n">RAII_Transaction</sp=
an><span class=3D"gmail-p">(unsigned int)</span>
<a name=3D"db_operations.cpp-164" style=3D"color:rgb(0,82,204)"></a><span c=
lass=3D"gmail-p">{</span>
<span class=3D"gmail-k" style=3D"font-weight:700">try</span>
<a name=3D"db_operations.cpp-168" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-p">{</span>
<a name=3D"db_operations.cpp-169" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-n">rollback</span><span class=3D"gmail-p">();</sp=
an>
<a name=3D"db_operations.cpp-170" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-p">}</span>
<a name=3D"db_operations.cpp-171" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-k" style=3D"font-weight:700">catch</span><span class=
=3D"gmail-p">(...)</span>
<a name=3D"db_operations.cpp-172" style=3D"color:rgb(0,82,204)"></a> =
<span class=3D"gmail-p">{</span>
<a name=3D"db_operations.cpp-173" style=3D"color:rgb(0,82,204)"></a> =
//...</pre><pre style=3D"margin-top:0px;margin-bottom:0px;padding:0p=
x;font-family:Consolas,Menlo,"Liberation Mono",Courier,monospace;=
font-size:12px;line-height:1.4;letter-spacing:0px;color:rgb(23,43,77)"> =
<span class=3D"gmail-p">}</span>
<a name=3D"db_operations.cpp-175" style=3D"color:rgb(0,82,204)"></a> <sp=
an class=3D"gmail-p">}</span>
<span class=3D"gmail-p">}</span></pre></div><div></div></div><div><br></div=
><div>Do you people agree this is enough motivation?</div><div><br></div><d=
iv>Thanks,</div><div><br></div><div>=C2=A0 =C2=A0 Daniel.</div><div><br></d=
iv>-- <br><div class=3D"gmail_signature">Who=E2=80=99s got the sweetest dis=
position?<br>One guess, that=E2=80=99s who?<br>Who=E2=80=99d never, ever st=
art an argument?<br>Who never shows a bit of temperament?<br>Who's neve=
r wrong but always right?<br>Who'd never dream of starting a fight?<br>=
Who get stuck with all the bad luck? </div>
</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/CAFdMc-362Wu239Tf-q2qSkUu6GCYu1ekFT-G=
PSETjGuFT6O5%2Bg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFdMc-362Wu239=
Tf-q2qSkUu6GCYu1ekFT-GPSETjGuFT6O5%2Bg%40mail.gmail.com</a>.<br />
--001a114bdc581efe7c05535ffc7a--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sun, 2 Jul 2017 20:25:00 -0700 (PDT)
Raw View
------=_Part_1385_1652170897.1499052300162
Content-Type: multipart/alternative;
boundary="----=_Part_1386_174593303.1499052300163"
------=_Part_1386_174593303.1499052300163
Content-Type: text/plain; charset="UTF-8"
On Sunday, July 2, 2017 at 9:50:02 PM UTC-4, dgutson wrote:
>
> Despite the fact that std::uncaught_exceptions has been approved, I wanted
> to survey a potential acceptance of an alternative:
>
No. As I type this, I have literally not read any further than this. No
matter the merits of the alternative, my answer is no.
We have a solution to this problem. Is it a perfect solution? No. But it is
an *adequate* solution. And considering that the problem only comes up in a
select few classes, we do not have any particular need for a language
solution here.
the ability to overload (and potentially =delete) a second version of
> destructors: one that accepts an unsigned integer representing the number
> of uncaught exception, that is, differentiate the destructor called not
> during unwinding (the current signature) and a destructor called when
> unwinding is ongoing.
>
> If only ~T() is provided, then it would be a dual-intention destructor: it
> will be called in both scenarios (during unwinding and not during
> unwinding).
> If only ~T(unsigned int) is provided, then it would be also a
> dual-intention destructor, called with 0 when there is not unwinding in
> progress, and greater than zero with the number of exceptions.
> If both ~T() and ~T(unsigned int) are provided, then ~T() is called when
> no unwinding, and ~T(usigned int) is called when unwinding with the
> argument greater than zero.
>
> Why? Because I found that all the times I had to use
> std::uncaught_exception/s, the true/else parts of the if had nothing in
> common, that is, the destructor had to do completely different stuff, so I
> think that I could make sense to arrange the code in two semantic-separated
> methods. It would not just be about avoiding a conditional. Inheritance
> could also get fancy, though I did not elaborate about it yet.
>
> Let me show you a real-life example: a DB Transaction RAII object:
>
Here's the problem: your code is *broken*. It's broken for the same reasons
why `std::uncaught_exception` is deprecated and was replaced with
`std::uncaught_exception*s*`
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3614.pdf>. Allow
me to re-write your examples so that they aren't broken (note that
`exception_count` is the value that `std::uncaught_exception` had when the
object was constructed. It's a member variable).
With `std::uncaught_exceptions`:
Db::RAII_Transaction::~RAII_Transaction()
{
if (std::uncaught_exceptions() != exception_count)
{
try
{
rollback();
}
catch(...)
{
//...
}
}
else if (doCommit)
{
try
{
commit();
}
catch (...)
{
//...
}
}
}
Now, with your feature:
Db::RAII_Transaction::~RAII_Transaction()
{
if (doCommit)
{
try
{
commit();
}
catch (...)
{
//...
}
}
}
Db::RAII_Transaction::~RAII_Transaction(unsigned int curr_exception_count)
{
if (curr_exception_count != exception_count)
{
try
{
rollback();
}
catch(...)
{
//...
}
}
else if (doCommit)
{
try
{
commit();
}
catch (...)
{
//...
}
}
}
See how the committing code has to be replicated? This is because your
feature divides the destructor into two cases: no exceptions are being
processed, and some exceptions are being processed. But the real
determining factor is not how many exceptions are being processed; the real
question is "is this destructor being called because the stack is being
unwound?"
The way to answer that question is to test `uncaught_exceptions` against
the number of uncaught exceptions from the constructor. If the numbers are
the same, then we know that this class was created and destroyed all within
the same unwinding context. If the numbers are different, then we know that
this class is being destroyed specifically because of unwinding.
--
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/3c541530-45fa-42e7-bd53-a9c7ceca4e0d%40isocpp.org.
------=_Part_1386_174593303.1499052300163
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Sunday, July 2, 2017 at 9:50:02 PM UTC-4, dgutson wrote=
:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bo=
rder-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Despite the =
fact that std::uncaught_exceptions has been approved, I wanted to survey a =
potential acceptance of an alternative:</div></blockquote><div><br>No. As I=
type this, I have literally not read any further than this. No matter the =
merits of the alternative, my answer is no.<br><br>We have a solution to th=
is problem. Is it a perfect solution? No. But it is an <i>adequate</i> solu=
tion. And considering that the problem only comes up in a select few classe=
s, we do not have any particular need for a language solution here.<br><br>=
</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8=
ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">the abi=
lity to overload (and potentially =3Ddelete) a second version of destructor=
s: one that accepts an unsigned integer representing the number of uncaught=
exception, that is, differentiate the destructor called not during unwindi=
ng (the current signature) and a destructor called when unwinding is ongoin=
g.<div><br></div><div>If only ~T() is provided, then it would be a dual-int=
ention destructor: it will be called in both scenarios (during unwinding an=
d not during unwinding).</div><div>If only ~T(unsigned int) is provided, th=
en it would be also a dual-intention destructor, called with 0 when there i=
s not unwinding in progress, and greater than zero with the number of excep=
tions.</div><div>If both ~T() and ~T(unsigned int) are provided, then ~T() =
is called when no unwinding, and ~T(usigned int) is called when unwinding w=
ith the argument greater than zero.</div></div></blockquote><blockquote cla=
ss=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #=
ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><br></div><div>Why? Bec=
ause I found that all the times I had to use std::uncaught_exception/s, the=
true/else parts of the if had nothing in common, that is, the destructor h=
ad to do completely different stuff, so I think that I could make sense to =
arrange the code in two semantic-separated methods. It would not just be ab=
out avoiding a conditional. Inheritance could also get fancy, though I did =
not elaborate about it yet.</div><div><br></div><div>Let me show you a real=
-life example: a DB Transaction RAII object:</div></div></blockquote><div><=
br>Here's the problem: your code is <i>broken</i>. It's broken for =
the <a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n361=
4.pdf">same reasons why `std::uncaught_exception` is deprecated and was rep=
laced with `std::uncaught_exception<u><i><b>s</b></i></u>`</a>. Allow me to=
re-write your examples so that they aren't broken (note that `exceptio=
n_count` is the value that `std::uncaught_exception` had when the object wa=
s constructed. It's a member variable).<br><br>With `std::uncaught_exce=
ptions`:<br><br><div style=3D"background-color: rgb(250, 250, 250); border-=
color: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflow=
-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div =
class=3D"subprettyprint"><span style=3D"color: #606;" class=3D"styled-by-pr=
ettify">Db</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">RAII_Tra=
nsaction</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::=
~</span><span style=3D"color: #000;" class=3D"styled-by-prettify">RAII_Tran=
saction</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">if</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">uncaught_exceptions</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">!=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> exception_count</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">try</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 rol=
lback</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">catch</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(...)</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//.=
...</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">else</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>if</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">doCommit</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">try</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 commit</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">();</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">catch</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(...)</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">//...</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">}</span></div></code></div><br>Now, with your feature:<b=
r><br><div style=3D"background-color: rgb(250, 250, 250); border-color: rgb=
(187, 187, 187); border-style: solid; border-width: 1px; overflow-wrap: bre=
ak-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"s=
ubprettyprint"><span style=3D"color: #606;" class=3D"styled-by-prettify">Db=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">RAII_Transaction</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">::~</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">RAII_Transaction</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">if</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">doCommit</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">try</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 commit</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">catch</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(...)</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify"=
>//...</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br=
></span><span style=3D"color: #606;" class=3D"styled-by-prettify">Db</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">RAII_Transaction</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">::~</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">RAII_Transaction</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">unsigned</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> curr_exception_count</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">if</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
curr_exception_count </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">!=3D</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> exception_count</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">try</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
rollback</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">catch</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(...)</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify"=
>//...</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">else</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">if</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">doCommit</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">try</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 commit</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">cat=
ch</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(...)</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #800;" =
class=3D"styled-by-prettify">//...</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">}</span></div></code></div><br>See how the =
committing code has to be replicated? This is because your feature divides =
the destructor into two cases: no exceptions are being processed, and some =
exceptions are being processed. But the real determining factor is not how =
many exceptions are being processed; the real question is "is this des=
tructor being called because the stack is being unwound?"<br><br>The w=
ay to answer that question is to test `uncaught_exceptions` against the num=
ber of uncaught exceptions from the constructor. If the numbers are the sam=
e, then we know that this class was created and destroyed all within the sa=
me unwinding context. If the numbers are different, then we know that this =
class is being destroyed specifically because of unwinding.</div><br></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/3c541530-45fa-42e7-bd53-a9c7ceca4e0d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/3c541530-45fa-42e7-bd53-a9c7ceca4e0d=
%40isocpp.org</a>.<br />
------=_Part_1386_174593303.1499052300163--
------=_Part_1385_1652170897.1499052300162--
.