diff mbox

Add C++11 const char* overloads for exception classes.

Message ID 508A9A0D.8040305@verizon.net
State New
Headers show

Commit Message

Ed Smith-Rowland Oct. 26, 2012, 2:11 p.m. UTC
Committed.
2012-10-26  Edward Smith-Rowland  <3dw4rd@verizon.net>

	* include/std/system_error (system_error(error_code, const char*),
	system_error(int, const error_category&, const char*)): New.
	* include/std/stdexcept ( logic_error(const char*),
	domain_error(const char*), invalid_argument(const char*),
	length_error(const char*), out_of_range(const char*),
	runtime_error(const char*), range_error(const char*),
	overflow_error(const char*), underflow_error(const char*)): New.
	* config/abi/pre/gnu.ver: Add symbols for logic_error const char* ctors.

Comments

Paolo Carlini Oct. 26, 2012, 2:26 p.m. UTC | #1
On 10/26/2012 04:11 PM, Ed Smith-Rowland wrote:
> Committed.
I can't find the message actually approving the patch. And personally 
I'm a bit nervous about it.

Paolo.
Ed Smith-Rowland Oct. 26, 2012, 2:36 p.m. UTC | #2
On 10/26/2012 10:26 AM, Paolo Carlini wrote:
> On 10/26/2012 04:11 PM, Ed Smith-Rowland wrote:
>> Committed.
> I can't find the message actually approving the patch. And personally 
> I'm a bit nervous about it.
>
> Paolo.
>
Sorry, i though it was OK. Do you want me to roll back?  do you want to?

Ed
Ed Smith-Rowland Oct. 26, 2012, 2:39 p.m. UTC | #3
On 10/26/2012 10:26 AM, Paolo Carlini wrote:
> On 10/26/2012 04:11 PM, Ed Smith-Rowland wrote:
>> Committed.
> I can't find the message actually approving the patch. And personally 
> I'm a bit nervous about it.
>
> Paolo.
>
Well, the commit had failed anyway... ChangeLog out of date.

So I'll wait.

Ed
Paolo Carlini Oct. 26, 2012, 2:40 p.m. UTC | #4
On 10/26/2012 04:36 PM, Ed Smith-Rowland wrote:
> On 10/26/2012 10:26 AM, Paolo Carlini wrote:
>> On 10/26/2012 04:11 PM, Ed Smith-Rowland wrote:
>>> Committed.
>> I can't find the message actually approving the patch. And personally 
>> I'm a bit nervous about it.
>>
>> Paolo.
>>
> Sorry, i though it was OK. Do you want me to roll back?  do you want to?
Yes please, thanks a lot. Bothe because of the export issue, also 
noticed by Benjamin, and because I seem to remember some trickery (which 
led me at the time to write down that long comment instead of actually 
doing the whole work ;)

Please be patient,
Thanks,
Paolo.
diff mbox

Patch

Index: include/std/system_error
===================================================================
--- include/std/system_error	(revision 192755)
+++ include/std/system_error	(working copy)
@@ -1,6 +1,7 @@ 
 // <system_error> -*- C++ -*-
 
-// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2007-2012
+// Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -318,17 +319,13 @@ 
     system_error(error_code __ec, const string& __what)
     : runtime_error(__what + ": " + __ec.message()), _M_code(__ec) { }
 
-    /*
-     * TODO: Add const char* ctors to all exceptions.
-     *
-     * system_error(error_code __ec, const char* __what)
-     * : runtime_error(__what + (": " + __ec.message())), _M_code(__ec) { }
-     *
-     * system_error(int __v, const error_category& __ecat, const char* __what)
-     * : runtime_error(__what + (": " + __ec.message())),
-     *   _M_code(error_code(__v, __ecat)) { }
-     */
+    system_error(error_code __ec, const char* __what)
+    : runtime_error(__what + (": " + __ec.message())), _M_code(__ec) { }
 
+    system_error(int __v, const error_category& __ecat, const char* __what)
+    : runtime_error(__what + (": " + error_code(__v, __ecat).message())),
+      _M_code(__v, __ecat) { }
+
     system_error(int __v, const error_category& __ecat)
     : runtime_error(error_code(__v, __ecat).message()),
       _M_code(__v, __ecat) { }
Index: include/std/stdexcept
===================================================================
--- include/std/stdexcept	(revision 192755)
+++ include/std/stdexcept	(working copy)
@@ -1,6 +1,6 @@ 
 // Standard exception classes  -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2005, 2007, 2009, 2010, 2011
+// Copyright (C) 2001, 2002, 2005, 2007, 2009-2012
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -59,8 +59,11 @@ 
 
   public:
     /** Takes a character string describing the error.  */
-    explicit 
-    logic_error(const string& __arg);
+    explicit logic_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+    explicit logic_error(const char* __arg)
+    : logic_error(string(__arg)) { }
+#endif
 
     virtual ~logic_error() _GLIBCXX_USE_NOEXCEPT;
 
@@ -76,6 +79,10 @@ 
   {
   public:
     explicit domain_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+    explicit domain_error(const char* __arg)
+    : domain_error(string(__arg)) { }
+#endif
     virtual ~domain_error() _GLIBCXX_USE_NOEXCEPT;
   };
 
@@ -84,6 +91,10 @@ 
   {
   public:
     explicit invalid_argument(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+    explicit invalid_argument(const char* __arg)
+    : invalid_argument(string(__arg)) { }
+#endif
     virtual ~invalid_argument() _GLIBCXX_USE_NOEXCEPT;
   };
 
@@ -93,6 +104,10 @@ 
   {
   public:
     explicit length_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+    explicit length_error(const char* __arg)
+    : length_error(string(__arg)) { }
+#endif
     virtual ~length_error() _GLIBCXX_USE_NOEXCEPT;
   };
 
@@ -102,6 +117,10 @@ 
   {
   public:
     explicit out_of_range(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+    explicit out_of_range(const char* __arg)
+    : out_of_range(string(__arg)) { }
+#endif
     virtual ~out_of_range() _GLIBCXX_USE_NOEXCEPT;
   };
 
@@ -116,8 +135,11 @@ 
 
   public:
     /** Takes a character string describing the error.  */
-    explicit 
-    runtime_error(const string& __arg);
+    explicit runtime_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+    explicit runtime_error(const char* __arg)
+    : runtime_error(string(__arg)) { }
+#endif
 
     virtual ~runtime_error() _GLIBCXX_USE_NOEXCEPT;
 
@@ -132,6 +154,10 @@ 
   {
   public:
     explicit range_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+    explicit range_error(const char* __arg)
+    : range_error(string(__arg)) { }
+#endif
     virtual ~range_error() _GLIBCXX_USE_NOEXCEPT;
   };
 
@@ -140,6 +166,10 @@ 
   {
   public:
     explicit overflow_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+    explicit overflow_error(const char* __arg)
+    : overflow_error(string(__arg)) { }
+#endif
     virtual ~overflow_error() _GLIBCXX_USE_NOEXCEPT;
   };
 
@@ -148,6 +178,10 @@ 
   {
   public:
     explicit underflow_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+    explicit underflow_error(const char* __arg)
+    : underflow_error(string(__arg)) { }
+#endif
     virtual ~underflow_error() _GLIBCXX_USE_NOEXCEPT;
   };
 
Index: config/abi/pre/gnu.ver
===================================================================
--- config/abi/pre/gnu.ver	(revision 192755)
+++ config/abi/pre/gnu.ver	(working copy)
@@ -1339,6 +1339,10 @@ 
     # construction vtable
     _ZTCSt*;
 
+    # const char* ctors for logic_error.
+    _ZNSt11logic_errorC1EPKc;
+    _ZNSt11logic_errorC2EPKc;
+
 } GLIBCXX_3.4.17;
 
 # Symbols in the support library (libsupc++) have their own tag.