[config] Proposed BOOST_NOEXCEPT_NOTHROW macro

The three current BOOST_NOEXCEPT* macro variants miss the case where C++03 code has a "throw()" throw-specifier. Classes that derive from standard library exceptions need this to avoid breaking code on C++03 compilers. I'm not enamored with the BOOST_NOEXCEPT_NOTHROW name, so feel free to offer suggestions for alternate names. Here is the full set of macros: #ifdef BOOST_NO_NOEXCEPT # define BOOST_NOEXCEPT # define BOOST_NOEXCEPT_NOTHROW throw() <---- new macro # define BOOST_NOEXCEPT_IF(Predicate) # define BOOST_NOEXCEPT_EXPR(Expression) false #else # define BOOST_NOEXCEPT noexcept # define BOOST_NOEXCEPT_NOTHROW noexcept <---- new macro # define BOOST_NOEXCEPT_IF(Predicate) noexcept((Predicate)) # define BOOST_NOEXCEPT_EXPR(Expression) noexcept((Expression)) #endif Unless there are objections, I'll commit the changes Wednesday afternoon Eastern US time. --Beman

Le 28/08/12 23:22, Beman Dawes a écrit :
The three current BOOST_NOEXCEPT* macro variants miss the case where C++03 code has a "throw()" throw-specifier. Classes that derive from standard library exceptions need this to avoid breaking code on C++03 compilers.
I'm not enamored with the BOOST_NOEXCEPT_NOTHROW name, so feel free to offer suggestions for alternate names.
Here is the full set of macros:
#ifdef BOOST_NO_NOEXCEPT # define BOOST_NOEXCEPT # define BOOST_NOEXCEPT_NOTHROW throw() <---- new macro # define BOOST_NOEXCEPT_IF(Predicate) # define BOOST_NOEXCEPT_EXPR(Expression) false #else # define BOOST_NOEXCEPT noexcept # define BOOST_NOEXCEPT_NOTHROW noexcept <---- new macro # define BOOST_NOEXCEPT_IF(Predicate) noexcept((Predicate)) # define BOOST_NOEXCEPT_EXPR(Expression) noexcept((Expression)) #endif
Unless there are objections, I'll commit the changes Wednesday afternoon Eastern US time.
I have no major problem with the additional macro BOOST_NOEXCEPT_NOTHROW , but I don't see why it should be committed so quickly. I will cal it BOOST_NOEXCEPT_OR_NOTHROW. My question is what macro will you use you implement noexcept in Boost.System. If you don't want to break c++03 compilers I think it should be BOOST_NOEXCEPT. Could you confirm? Best, Vicente

On Tue, Aug 28, 2012 at 6:27 PM, Vicente J. Botet Escriba <vicente.botet@wanadoo.fr> wrote:
Le 28/08/12 23:22, Beman Dawes a écrit :
The three current BOOST_NOEXCEPT* macro variants miss the case where C++03 code has a "throw()" throw-specifier. Classes that derive from standard library exceptions need this to avoid breaking code on C++03 compilers.
I'm not enamored with the BOOST_NOEXCEPT_NOTHROW name, so feel free to offer suggestions for alternate names.
Here is the full set of macros:
#ifdef BOOST_NO_NOEXCEPT # define BOOST_NOEXCEPT # define BOOST_NOEXCEPT_NOTHROW throw() <---- new macro # define BOOST_NOEXCEPT_IF(Predicate) # define BOOST_NOEXCEPT_EXPR(Expression) false #else # define BOOST_NOEXCEPT noexcept # define BOOST_NOEXCEPT_NOTHROW noexcept <---- new macro # define BOOST_NOEXCEPT_IF(Predicate) noexcept((Predicate)) # define BOOST_NOEXCEPT_EXPR(Expression) noexcept((Expression)) #endif
Unless there are objections, I'll commit the changes Wednesday afternoon Eastern US time.
I have no major problem with the additional macro BOOST_NOEXCEPT_NOTHROW , but I don't see why it should be committed so quickly.
No real need, just wanting to clear it off my "half-done" list. (With Git, I could just stash my changes, but that's a bit of a pain with subversion.)
I will cal it BOOST_NOEXCEPT_OR_NOTHROW.
I considered that, but was put off by its length. BOOST_NOEXCEPT_OR_NOTHROW is clearer and the transition from throw() to noexcept is confusing, so let's got with BOOST_NOEXCEPT_OR_NOTHROW
My question is what macro will you use you implement noexcept in Boost.System. If you don't want to break c++03 compilers I think it should be BOOST_NOEXCEPT. Could you confirm?
Anything currently decorated with throw() has to use BOOST_NOEXCEPT_OR_NOTHROW. #include <stdexcept> class my_error : public std::runtime_error { public: const char* what() const throw() { return "bingo"; } }; For a C++03 compiler, replacing the throw() with BOOST_NOEXCEPT is equivalent to removing it. gcc 4.7 in C++03 mode will report an error: c:\mingw\4.7\bin\../lib/gcc/mingw32/4.7.0/include/c++/stdexcept:127:5: error: overriding 'virtual const char* std::runtime_error::what() const throw ()' Even for compilers that don't report this as an error, it is a silent change in semantics that can be avoided by using BOOST_NOEXCEPT_OR_NOTHROW. For example, class system_error has three signatures that need noexcept for C++11. All three of these are currently marked throw(), so all three have to be replaced with BOOST_NOEXCEPT_OR_NOTHROW. --Beman

Beman Dawes wrote:
On Tue, Aug 28, 2012 at 6:27 PM, Vicente J. Botet Escriba <vicente.botet@wanadoo.fr> wrote:
Le 28/08/12 23:22, Beman Dawes a écrit :
The three current BOOST_NOEXCEPT* macro variants miss the case where C++03 code has a "throw()" throw-specifier. Classes that derive from standard library exceptions need this to avoid breaking code on C++03 compilers.
I think I suggested the need for that in the beginning. It is an important case as you've found.
I'm not enamored with the BOOST_NOEXCEPT_NOTHROW name, so feel free to offer suggestions for alternate names.
I will cal it BOOST_NOEXCEPT_OR_NOTHROW.
I considered that, but was put off by its length. BOOST_NOEXCEPT_OR_NOTHROW is clearer and the transition from throw() to noexcept is confusing, so let's got with BOOST_NOEXCEPT_OR_NOTHROW
I agree that the name is long, but it is clear. What about BOOST_NOTHROW? It doesn't transition well to an all-C++11 world (only noexcept), but both throw() and noexcept mean the function emits (or should emit) no exceptions, so the name conveys the right idea. Maybe BOOST_THROWS_NOTHING to avoid the old connotation of "NOTHROW"? _____ Rob Stewart robert.stewart@sig.com Software Engineer using std::disclaimer; Dev Tools & Components Susquehanna International Group, LLP http://www.sig.com ________________________________ IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.

On Wed, Aug 29, 2012 at 7:48 AM, Stewart, Robert <Robert.Stewart@sig.com> wrote:
Beman Dawes wrote:
On Tue, Aug 28, 2012 at 6:27 PM, Vicente J. Botet Escriba <vicente.botet@wanadoo.fr> wrote:
Le 28/08/12 23:22, Beman Dawes a écrit :
The three current BOOST_NOEXCEPT* macro variants miss the case where C++03 code has a "throw()" throw-specifier. Classes that derive from standard library exceptions need this to avoid breaking code on C++03 compilers.
I think I suggested the need for that in the beginning. It is an important case as you've found.
Yeah, I remember that now. Apparently it went over my head. Apologies.
I'm not enamored with the BOOST_NOEXCEPT_NOTHROW name, so feel free to offer suggestions for alternate names.
I will cal it BOOST_NOEXCEPT_OR_NOTHROW.
I considered that, but was put off by its length. BOOST_NOEXCEPT_OR_NOTHROW is clearer and the transition from throw() to noexcept is confusing, so let's got with BOOST_NOEXCEPT_OR_NOTHROW
I agree that the name is long, but it is clear.
What about BOOST_NOTHROW? It doesn't transition well to an all-C++11 world (only noexcept), but both throw() and noexcept mean the function emits (or should emit) no exceptions, so the name conveys the right idea. Maybe BOOST_THROWS_NOTHING to avoid the old connotation of "NOTHROW"?
My thinking was that there was some small advantage to beginning each of the noexcept macros with BOOST_NOEXCEPT. I worry that BOOST_THROWS_NOTHING would be misconstrued as a replacement for "Throws: Nothing" specifications, and that isn't the case. BOOST_NEVER_THROWS might be a bit better. But I think I still prefer BOOST_NOEXCEPT_OR_NOTHROW. Or the original suggested BOOST_NOEXCEPT_NOTHROW. --Beman

On 2012-08-29 15:31, Beman Dawes wrote:
My thinking was that there was some small advantage to beginning each of the noexcept macros with BOOST_NOEXCEPT.
I worry that BOOST_THROWS_NOTHING would be misconstrued as a replacement for "Throws: Nothing" specifications, and that isn't the case. BOOST_NEVER_THROWS might be a bit better. But I think I still prefer BOOST_NOEXCEPT_OR_NOTHROW. Or the original suggested BOOST_NOEXCEPT_NOTHROW.
--Beman
BOOST_NOEXCEPT_AND_NOTHROW ? OR sounds like a choice. Just my 2ct.

on Wed Aug 29 2012, Roland Bock <rbock-AT-eudoxos.de> wrote:
On 2012-08-29 15:31, Beman Dawes wrote:
My thinking was that there was some small advantage to beginning each of the noexcept macros with BOOST_NOEXCEPT.
I worry that BOOST_THROWS_NOTHING would be misconstrued as a replacement for "Throws: Nothing" specifications, and that isn't the case. BOOST_NEVER_THROWS might be a bit better. But I think I still prefer BOOST_NOEXCEPT_OR_NOTHROW. Or the original suggested BOOST_NOEXCEPT_NOTHROW.
--Beman
BOOST_NOEXCEPT_AND_NOTHROW ? OR sounds like a choice.
Should just be BOOST_NOEXCEPT, IMO. Design for the future. -- Dave Abrahams BoostPro Computing Software Development Training http://www.boostpro.com Clang/LLVM/EDG Compilers C++ Boost

On Sun, Sep 2, 2012 at 9:19 AM, Dave Abrahams <dave@boostpro.com> wrote:
on Wed Aug 29 2012, Roland Bock <rbock-AT-eudoxos.de> wrote:
On 2012-08-29 15:31, Beman Dawes wrote:
My thinking was that there was some small advantage to beginning each of the noexcept macros with BOOST_NOEXCEPT.
I worry that BOOST_THROWS_NOTHING would be misconstrued as a replacement for "Throws: Nothing" specifications, and that isn't the case. BOOST_NEVER_THROWS might be a bit better. But I think I still prefer BOOST_NOEXCEPT_OR_NOTHROW. Or the original suggested BOOST_NOEXCEPT_NOTHROW.
--Beman
BOOST_NOEXCEPT_AND_NOTHROW ? OR sounds like a choice.
Should just be BOOST_NOEXCEPT, IMO. Design for the future.
We already have a BOOST_NOEXCEPT that expands to nothing in C++03, right? I understood the point of this proposed macro was to support those decorators on virtual functions that were "throw ()" in C++03 but got changed to "noexcept(true)" in C++11. - Jeff

Jeffrey Lee Hellrung wrote:
On Sun, Sep 2, 2012 at 9:19 AM, Dave Abrahams <dave@boostpro.com> wrote:
on Wed Aug 29 2012, Roland Bock <rbock-AT-eudoxos.de> wrote:
On 2012-08-29 15:31, Beman Dawes wrote:
My thinking was that there was some small advantage to beginning each of the noexcept macros with BOOST_NOEXCEPT.
I worry that BOOST_THROWS_NOTHING would be misconstrued as a replacement for "Throws: Nothing" specifications, and that isn't the case. BOOST_NEVER_THROWS might be a bit better. But I think I still prefer BOOST_NOEXCEPT_OR_NOTHROW. Or the original suggested BOOST_NOEXCEPT_NOTHROW.
BOOST_NOEXCEPT_AND_NOTHROW ? OR sounds like a choice.
Should just be BOOST_NOEXCEPT, IMO. Design for the future.
We already have a BOOST_NOEXCEPT that expands to nothing in C++03, right? I understood the point of this proposed macro was to support those decorators on virtual functions that were "throw ()" in C++03 but got changed to "noexcept(true)" in C++11.
There are two cases. In C++03, some functions had to be decorated with throw(), but most, even if they didn't throw, were left with no decoration because throw() is a pain for multiple reasons. Beman created BOOST_NOEXCEPT to handle the latter case: a function that throws, and hopefully is documented as throwing, nothing becoming noexcept in C++11. Now he needs a macro that is noexcept in C++11, but throw() in C++03. Given that BOOST_NOEXCEPT has already been used for the former, another name is needed for the latter. "BOOST_NOTHROW" is short, conveys the right idea, but isn't forward looking. Then again, when we can ignore C++03, s/BOOST_NOTHROW/BOOST_NOEXCEPT/ would bring all code into C++11 without harm. _____ Rob Stewart robert.stewart@sig.com Software Engineer using std::disclaimer; Dev Tools & Components Susquehanna International Group, LLP http://www.sig.com ________________________________ IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.

On Mon, Sep 3, 2012 at 12:37 PM, Stewart, Robert <Robert.Stewart@sig.com> wrote:
Jeffrey Lee Hellrung wrote:
On Sun, Sep 2, 2012 at 9:19 AM, Dave Abrahams <dave@boostpro.com> wrote:
on Wed Aug 29 2012, Roland Bock <rbock-AT-eudoxos.de> wrote:
On 2012-08-29 15:31, Beman Dawes wrote:
My thinking was that there was some small advantage to beginning each of the noexcept macros with BOOST_NOEXCEPT.
I worry that BOOST_THROWS_NOTHING would be misconstrued as a replacement for "Throws: Nothing" specifications, and that isn't the case. BOOST_NEVER_THROWS might be a bit better. But I think I still prefer BOOST_NOEXCEPT_OR_NOTHROW. Or the original suggested BOOST_NOEXCEPT_NOTHROW.
BOOST_NOEXCEPT_AND_NOTHROW ? OR sounds like a choice.
Should just be BOOST_NOEXCEPT, IMO. Design for the future.
We already have a BOOST_NOEXCEPT that expands to nothing in C++03, right? I understood the point of this proposed macro was to support those decorators on virtual functions that were "throw ()" in C++03 but got changed to "noexcept(true)" in C++11.
There are two cases. In C++03, some functions had to be decorated with throw(), but most, even if they didn't throw, were left with no decoration because throw() is a pain for multiple reasons.
Beman created BOOST_NOEXCEPT to handle the latter case: a function that throws, and hopefully is documented as throwing, nothing becoming noexcept in C++11. Now he needs a macro that is noexcept in C++11, but throw() in C++03.
Given that BOOST_NOEXCEPT has already been used for the former, another name is needed for the latter.
"BOOST_NOTHROW" is short, conveys the right idea, but isn't forward looking. Then again, when we can ignore C++03, s/BOOST_NOTHROW/BOOST_NOEXCEPT/ would bring all code into C++11 without harm.
That's an interesting suggestion. We already have BOOST_CONSTEXPR_OR_CONST, so I'm still leaning toward BOOST_NOEXCEPT_OR_NOTHROW just for consistency. We can do a global change to BOOST_NOEXCEPT for that name, too, when we no longer want to support C++03 compilers. Given that it is a 3-day holiday weekend in the US, I'll give it another day or two. But then we need to move on to higher priority work. --Beman

On Mon, Sep 3, 2012 at 2:11 PM, Beman Dawes <bdawes@acm.org> wrote:
On Mon, Sep 3, 2012 at 12:37 PM, Stewart, Robert <Robert.Stewart@sig.com> wrote: ...
"BOOST_NOTHROW" is short, conveys the right idea, but isn't forward looking. Then again, when we can ignore C++03, s/BOOST_NOTHROW/BOOST_NOEXCEPT/ would bring all code into C++11 without harm.
That's an interesting suggestion.
We already have BOOST_CONSTEXPR_OR_CONST, so I'm still leaning toward BOOST_NOEXCEPT_OR_NOTHROW just for consistency. We can do a global change to BOOST_NOEXCEPT for that name, too, when we no longer want to support C++03 compilers.
Given that it is a 3-day holiday weekend in the US, I'll give it another day or two. But then we need to move on to higher priority work.
This finally got committed to trunk this morning, using the name BOOST_NOEXCEPT_OR_NOTHROW. Docs updated. Sorry for the delay, --Beman

In message <33DFA071B6DD6D4FB44851BDE4A72593198373@xchmbbal503.ds.susq.com>, "Stewart, Robert" <Robert.Stewart@sig.com> writes
Beman Dawes wrote:
On Tue, Aug 28, 2012 at 6:27 PM, Vicente J. Botet Escriba <vicente.botet@wanadoo.fr> wrote:
Le 28/08/12 23:22, Beman Dawes a écrit : ...
I'm not enamored with the BOOST_NOEXCEPT_NOTHROW name, so feel free to offer suggestions for alternate names.
I will cal it BOOST_NOEXCEPT_OR_NOTHROW.
I considered that, but was put off by its length. BOOST_NOEXCEPT_OR_NOTHROW is clearer and the transition from throw() to noexcept is confusing, so let's got with BOOST_NOEXCEPT_OR_NOTHROW
I agree that the name is long, but it is clear.
What about BOOST_NOTHROW? It doesn't transition well to an all-C++11 world (only noexcept), but both throw() and noexcept mean the function emits (or should emit) no exceptions, so the name conveys the right idea. Maybe BOOST_THROWS_NOTHING to avoid the old connotation of "NOTHROW"?
BOOST_NO_THROW? -- Alec Ross
participants (7)
-
Alec Ross
-
Beman Dawes
-
Dave Abrahams
-
Jeffrey Lee Hellrung, Jr.
-
Roland Bock
-
Stewart, Robert
-
Vicente J. Botet Escriba