Patchwork [v3] Implement DR 1517

login
register
mail settings
Submitter Paolo Carlini
Date Jan. 18, 2011, 11:13 a.m.
Message ID <4D3575C5.3020402@oracle.com>
Download mbox | patch
Permalink /patch/79287/
State New
Headers show

Comments

Paolo Carlini - Jan. 18, 2011, 11:13 a.m.
Hi,

tested x86_64-linux, committed to mainline.

Paolo.

/////////////////////
2011-01-18  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/bits/unique_ptr.h (default_delete<>::default_delete()):
	Declare defaulted per DR 1517.
	* testsuite/util/testsuite_common_types.h
	(constexpr_defaulted_default_constructible): Add.
	* testsuite/20_util/default_delete/cons/constexpr.cc: Use it.

Patch

Index: include/bits/unique_ptr.h
===================================================================
--- include/bits/unique_ptr.h	(revision 168946)
+++ include/bits/unique_ptr.h	(working copy)
@@ -47,7 +47,7 @@ 
   template<typename _Tp>
     struct default_delete
     {
-      constexpr default_delete() { }
+      constexpr default_delete() = default;
 
       template<typename _Up, typename = typename
 	       std::enable_if<std::is_convertible<_Up*, _Tp*>::value>::type>
@@ -68,7 +68,7 @@ 
   template<typename _Tp>
     struct default_delete<_Tp[]>
     {
-      constexpr default_delete() { }
+      constexpr default_delete() = default;
 
       void
       operator()(_Tp* __ptr) const
Index: testsuite/util/testsuite_common_types.h
===================================================================
--- testsuite/util/testsuite_common_types.h	(revision 168946)
+++ testsuite/util/testsuite_common_types.h	(working copy)
@@ -644,7 +644,7 @@ 
     template<typename _Tp, bool _IsLitp = std::is_literal_type<_Tp>::value>
       struct _Concept;
 
-    // NB: _Tp must be a literal type. 
+    // NB: _Tp must be a literal type.
     // Have to have user-defined default ctor for this to work.
     template<typename _Tp>
       struct _Concept<_Tp, true>
@@ -671,6 +671,24 @@ 
       }
   };
 
+  // Generator to test defaulted default constructor.
+  struct constexpr_defaulted_default_constructible
+  {
+    template<typename _Tp>
+      void
+      operator()()
+      {
+	struct _Concept
+	{
+	  void __constraint()
+	  { constexpr _Tp __v __attribute__((unused)) { }; }
+	};
+
+	void (_Concept::*__x)() __attribute__((unused))
+	  = &_Concept::__constraint;
+      }
+  };
+
   struct constexpr_single_value_constructible
   {
     template<typename _Ttesttype, typename _Tvaluetype, 
Index: testsuite/20_util/default_delete/cons/constexpr.cc
===================================================================
--- testsuite/20_util/default_delete/cons/constexpr.cc	(revision 168946)
+++ testsuite/20_util/default_delete/cons/constexpr.cc	(working copy)
@@ -23,7 +23,7 @@ 
 
 int main()
 {
-  __gnu_test::constexpr_default_constructible test;
+  __gnu_test::constexpr_defaulted_default_constructible test;
   test.operator()<std::default_delete<int>>();
   return 0;
 }