Topic: implicit noexcept specifier
Author: xavinaar@gmail.com
Date: Wed, 13 Jul 2016 05:43:02 -0700 (PDT)
Raw View
------=_Part_350_70919091.1468413782252
Content-Type: multipart/alternative;
boundary="----=_Part_351_885211911.1468413782252"
------=_Part_351_885211911.1468413782252
Content-Type: text/plain; charset=UTF-8
There is proposal draft for *noexcept(auto)*, yet it has one flaw: function
noexcept-ness cannot be deduced in cases except:
1. inline functions
2. lambda functions
3. virtual functions, overriding noexcept(true) base functions.
The key point of my proposal is to make all those types of functions
implicitly noexcept iff those functions throw/call (possibly) throwing
functions only inside non-throwing try-block (one enclosed with catch-all
handler and that doesn't rethrow).
Motivation is to make all functions implicitly noexcept(true) where
applicable without even changing source code.
Example:
void func_noexcept() noexcept;
void func_except();
inline test_func1() { // implicit noexcept(true)
func_noexcept();
}
inline test_func2() { // noexcept(false)
func_except();
}
inline test_func3() { // implicit noexcept(true)
try {
func_except();
throw std::runtime_error("");
} catch (...) { }
}
inline test_func4() { // noexcept(false)
try {
func_except();
throw std::runtime_error("");
} catch (...) {
throw;
}
}
--
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/103c12bb-02a7-4999-b852-d8607be880b7%40isocpp.org.
------=_Part_351_885211911.1468413782252
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">There is proposal draft for <b>noexcept(auto)</b>, yet it =
has one flaw: function noexcept-ness cannot be deduced in cases except:<br>=
<ol><li>inline functions<br></li><li>lambda functions</li><li>virtual funct=
ions, overriding noexcept(true) base functions.</li></ol><p>The key point o=
f my proposal is to make all those types of functions implicitly noexcept i=
ff those functions throw/call (possibly) throwing functions only inside non=
-throwing try-block (one enclosed with catch-all handler and that doesn'=
;t rethrow).</p><p><br></p><p>Motivation is to make all functions implicitl=
y noexcept(true) where applicable without even changing source code.</p><p>=
<br></p><p>Example:</p><p><br></p><p>void func_noexcept() noexcept;<br>void=
func_except();<br><br>inline test_func1() { // implicit noexcept(true)<br>=
=C2=A0=C2=A0=C2=A0 func_noexcept();<br>}<br><br>inline test_func2() { // no=
except(false)<br>=C2=A0=C2=A0=C2=A0 func_except();<br>}<br><br>inline test_=
func3() { // implicit noexcept(true)<br>=C2=A0=C2=A0=C2=A0 try {<br>=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 func_except();<br>=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 throw std::runtime_error("");<br>=C2=A0=
=C2=A0=C2=A0 } catch (...) { }<br>}<br><br>inline test_func4() { // noexcep=
t(false)<br>=C2=A0=C2=A0=C2=A0 try {<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 func_except();<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 thro=
w std::runtime_error("");<br>=C2=A0=C2=A0=C2=A0 } catch (...) {<b=
r>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 throw;<br>=C2=A0=C2=A0=C2=A0 }=
<br>}<br></p></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/103c12bb-02a7-4999-b852-d8607be880b7%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/103c12bb-02a7-4999-b852-d8607be880b7=
%40isocpp.org</a>.<br />
------=_Part_351_885211911.1468413782252--
------=_Part_350_70919091.1468413782252--
.