Patchwork implement LWG 2145

login
register
mail settings
Submitter Jonathan Wakely
Date May 18, 2013, 11:11 p.m.
Message ID <CAH6eHdSzzuAvufZFGio7DknP9+rAkRvZD=qHekGTAQs-saQN2g@mail.gmail.com>
Download mbox | patch
Permalink /patch/244795/
State New
Headers show

Comments

Jonathan Wakely - May 18, 2013, 11:11 p.m.
* include/std/system_error (error_category::error_category()): LWG
        2145: Declare public and constexpr.
        * src/c++11/system_error.cc (error_category::error_category()): Move
        definition to ...
        * src/c++11/compatibility-c++0x.cc: Here.

Tested x86_64-linux, committed to trunk.

For 4.8 we can just make the constructor public but leave it non-inline.

Patch

diff --git a/libstdc++-v3/include/std/system_error b/libstdc++-v3/include/std/system_error
index b63b74e..d66b871 100644
--- a/libstdc++-v3/include/std/system_error
+++ b/libstdc++-v3/include/std/system_error
@@ -65,11 +65,14 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /// error_category
   class error_category
   {
-  protected:
+  public:
+#ifdef _GLIBCXX_COMPATIBILITY_CXX0X
     error_category() noexcept;
+#else
+    constexpr error_category() noexcept = default;
+#endif
 
-  public:
-    virtual ~error_category() noexcept;
+    virtual ~error_category();
 
     error_category(const error_category&) = delete;
     error_category& operator=(const error_category&) = delete;
diff --git a/libstdc++-v3/src/c++11/compatibility-c++0x.cc b/libstdc++-v3/src/c++11/compatibility-c++0x.cc
index fc84a5e..64a4a6c 100644
--- a/libstdc++-v3/src/c++11/compatibility-c++0x.cc
+++ b/libstdc++-v3/src/c++11/compatibility-c++0x.cc
@@ -119,6 +119,10 @@  namespace std _GLIBCXX_VISIBILITY(default)
     };
     constexpr bool system_clock::is_monotonic;
   } // namespace chrono
+
+  // gcc-4.9.0
+  // LWG 2145 changes this constructor to constexpr i.e. inline
+  error_category::error_category() noexcept = default;
 }
 
 #endif
diff --git a/libstdc++-v3/src/c++11/system_error.cc b/libstdc++-v3/src/c++11/system_error.cc
index 453c687..65dcef3 100644
--- a/libstdc++-v3/src/c++11/system_error.cc
+++ b/libstdc++-v3/src/c++11/system_error.cc
@@ -70,8 +70,6 @@  namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
-  error_category::error_category() noexcept = default;
-
   error_category::~error_category() noexcept = default;
 
   const error_category&