[c++0x patch] add std::make_exception_ptr

Jonathan Wakely jwakely.gcc@gmail.com
Fri May 7 01:05:00 GMT 2010


LWG DR 1130 renamed copy_exception to make_exception_ptr, this adds
the latter which simply forwards to the former

2010-05-07  Jonathan Wakely  <jwakely.gcc@gmail.com>

        * libsupc++/exception_ptr.h (make_exception_ptr): Add.
        * testsuite/18_support/exception_ptr/make_exception_ptr.cc: New.

tested x86_64/Linux, checked in to trunk

Jonathan
-------------- next part --------------
Index: libsupc++/exception_ptr.h
===================================================================
--- libsupc++/exception_ptr.h	(revision 159125)
+++ libsupc++/exception_ptr.h	(working copy)
@@ -160,6 +160,14 @@ namespace std 
 	}
     }
 
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
+  // 1130. copy_exception name misleading
+  /// Obtain an exception_ptr pointing to a copy of the supplied object.
+  template<typename _Ex>
+    exception_ptr 
+    make_exception_ptr(_Ex __ex) throw()
+    { return std::copy_exception<_Ex>(__ex); }
+
   // @} group exceptions
 } // namespace std
 
Index: testsuite/18_support/exception_ptr/make_exception_ptr.cc
===================================================================
--- testsuite/18_support/exception_ptr/make_exception_ptr.cc	(revision 0)
+++ testsuite/18_support/exception_ptr/make_exception_ptr.cc	(revision 0)
@@ -0,0 +1,38 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-atomic-builtins "" }
+
+// Copyright (C) 2010 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <exception>
+#include <testsuite_hooks.h>
+
+bool test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  std::exception_ptr p = std::make_exception_ptr(0);
+
+  VERIFY( !(p == 0) );
+}
+
+int main()
+{
+  test01();
+
+  return 0;
+}


More information about the Libstdc++ mailing list