Re: [patch] libstdc++/66055 add missing constructors to unordered containers

2015-05-16 Thread François Dumont

On 14/05/2015 15:47, Jonathan Wakely wrote:

Reported by Nathan and fixed by his patch. I added the tests.

Tested powerpc64le-linux, committed to trunk. This should be
backported too.


While backporting to debug and profile mode I noticed that those 
constructors were not the only missing ones. So here is a patch to 
complete them with debug and profile modes.


Moreover this patch:
- Remove explicit keyword on one of the unordered_map constructor, 
surely the result of a copy/paste

- Use constructor delegation as proposed by the Standard
- Move code to follow Standard description order, it is easier this way 
to check that nothing is missing.


* include/bits/unordered_map.h (unordered_map, unordered_multimap): Add
missing constructors.
* include/bits/unordered_set.h (unordered_set, unordered_multiset):
Likewise.
* include/debug/unordered_map (unordered_map, unordered_multimap): Add
missing constructors.
* include/debug/unordered_set (unordered_set, unordered_multiset):
Likewise.
* include/profile/unordered_map (unordered_map, 
unordered_multimap): Add

missing constructors.
* include/profile/unordered_set (unordered_set, unordered_multiset):
Likewise.
* testsuite/23_containers/unordered_map/cons/66055.cc: Add constructor
invocations.
* testsuite/23_containers/unordered_multimap/cons/66055.cc: Likewise.
* testsuite/23_containers/unordered_multiset/cons/66055.cc: Likewise.
* testsuite/23_containers/unordered_set/cons/66055.cc: Likewise.

Ok to commit ?

François

diff --git a/libstdc++-v3/include/bits/unordered_map.h b/libstdc++-v3/include/bits/unordered_map.h
index 069b859..6ace59d 100644
--- a/libstdc++-v3/include/bits/unordered_map.h
+++ b/libstdc++-v3/include/bits/unordered_map.h
@@ -146,17 +146,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   : _M_h(__n, __hf, __eql, __a)
   { }
 
-  unordered_map(size_type __n, const allocator_type& __a)
-  : _M_h(__n, hasher(), key_equal(), __a)
-  { }
-
-  explicit
-  unordered_map(size_type __n,
-		const hasher& __hf,
-		const allocator_type& __a)
-  : _M_h(__n, __hf, key_equal(), __a)
-  { }
-
   /**
*  @brief  Builds an %unordered_map from a range.
*  @param  __first  An input iterator.
@@ -233,6 +222,41 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	: _M_h(__l, __n, __hf, __eql, __a)
   { }
 
+  unordered_map(size_type __n, const allocator_type& __a)
+  : unordered_map(__n, hasher(), key_equal(), __a)
+  { }
+
+  unordered_map(size_type __n, const hasher& __hf,
+		const allocator_type& __a)
+  : unordered_map(__n, __hf, key_equal(), __a)
+  { }
+
+  template
+	unordered_map(_InputIterator __first, _InputIterator __last,
+		  size_type __n,
+		  const allocator_type& __a)
+	  : unordered_map(__first, __last, __n, hasher(), key_equal(), __a)
+	{ }
+
+  template
+	unordered_map(_InputIterator __first, _InputIterator __last,
+		  size_type __n, const hasher& __hf,
+		  const allocator_type& __a)
+	  : unordered_map(__first, __last, __n, __hf, key_equal(), __a)
+	{ }
+
+  unordered_map(initializer_list __l,
+		size_type __n,
+		const allocator_type& __a)
+	: unordered_map(__l, __n, hasher(), key_equal(), __a)
+  { }
+
+  unordered_map(initializer_list __l,
+		size_type __n, const hasher& __hf,
+		const allocator_type& __a)
+	: unordered_map(__l, __n, __hf, key_equal(), __a)
+  { }
+
   /// Copy assignment operator.
   unordered_map&
   operator=(const unordered_map&) = default;
@@ -872,16 +896,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   : _M_h(__n, __hf, __eql, __a)
   { }
 
-  unordered_multimap(size_type __n, const allocator_type& __a)
-  : _M_h(__n, hasher(), key_equal(), __a)
-  { }
-
-  unordered_multimap(size_type __n,
-			 const hasher& __hf,
-			 const allocator_type& __a)
-  : _M_h(__n, __hf, key_equal(), __a)
-  { }
-
   /**
*  @brief  Builds an %unordered_multimap from a range.
*  @param  __first An input iterator.
@@ -958,6 +972,41 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	: _M_h(__l, __n, __hf, __eql, __a)
   { }
 
+  unordered_multimap(size_type __n, const allocator_type& __a)
+  : unordered_multimap(__n, hasher(), key_equal(), __a)
+  { }
+
+  unordered_multimap(size_type __n, const hasher& __hf,
+			 const allocator_type& __a)
+  : unordered_multimap(__n, __hf, key_equal(), __a)
+  { }
+
+  template
+	unordered_multimap(_InputIterator __first, _InputIterator __last,
+			   size_type __n,
+			   const allocator_type& __a)
+	  : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a)
+	{ }
+
+  template
+	unordered_multimap(_InputIterator __first, _InputIterator __last,
+			   size_type __n, const hasher& __hf,
+			   const allocator_type& __a)
+	  : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a)
+	{ }
+
+  unordere

Re: [patch] libstdc++/66055 add missing constructors to unordered containers

2015-05-16 Thread Jonathan Wakely

On 16/05/15 11:39 +0200, François Dumont wrote:

On 14/05/2015 15:47, Jonathan Wakely wrote:

Reported by Nathan and fixed by his patch. I added the tests.

Tested powerpc64le-linux, committed to trunk. This should be
backported too.


While backporting to debug and profile mode I noticed that those 
constructors were not the only missing ones. So here is a patch to 
complete them with debug and profile modes.


Great, thanks.


@@ -233,6 +222,41 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
: _M_h(__l, __n, __hf, __eql, __a)
  { }

+  unordered_map(size_type __n, const allocator_type& __a)
+  : unordered_map(__n, hasher(), key_equal(), __a)
+  { }
+
+  unordered_map(size_type __n, const hasher& __hf,
+   const allocator_type& __a)
+  : unordered_map(__n, __hf, key_equal(), __a)
+  { }
+
+  template
+   unordered_map(_InputIterator __first, _InputIterator __last,
+ size_type __n,
+ const allocator_type& __a)
+ : unordered_map(__first, __last, __n, hasher(), key_equal(), __a)


The indentation is inconsistent here, the ctor-initializer-list is
indented further than necessary


@@ -891,7 +941,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   *  in the initializer list @a __l.
   *
   *  Note that the assignment completely changes the %unordered_multiset
-   *  and that the resulting %unordered_set's size is the same as the 
number
+   *  and that the resulting %unordered_multiset's size is the same as the 
number
   *  of elements assigned.  Old data may be lost.


Please reformat this to stay below 80 columns.

OK with those two tiny adjustments, thanks!



Re: [patch] libstdc++/66055 add missing constructors to unordered containers

2015-05-17 Thread François Dumont
Ok, I just commit fixing some other lines length except those having a 
long hyperlink, I didn't want to break those.


François


On 16/05/2015 21:32, Jonathan Wakely wrote:

On 16/05/15 11:39 +0200, François Dumont wrote:

On 14/05/2015 15:47, Jonathan Wakely wrote:

Reported by Nathan and fixed by his patch. I added the tests.

Tested powerpc64le-linux, committed to trunk. This should be
backported too.


While backporting to debug and profile mode I noticed that those 
constructors were not the only missing ones. So here is a patch to 
complete them with debug and profile modes.


Great, thanks.


@@ -233,6 +222,41 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
: _M_h(__l, __n, __hf, __eql, __a)
  { }

+  unordered_map(size_type __n, const allocator_type& __a)
+  : unordered_map(__n, hasher(), key_equal(), __a)
+  { }
+
+  unordered_map(size_type __n, const hasher& __hf,
+const allocator_type& __a)
+  : unordered_map(__n, __hf, key_equal(), __a)
+  { }
+
+  template
+unordered_map(_InputIterator __first, _InputIterator __last,
+  size_type __n,
+  const allocator_type& __a)
+  : unordered_map(__first, __last, __n, hasher(), key_equal(), __a)


The indentation is inconsistent here, the ctor-initializer-list is
indented further than necessary


@@ -891,7 +941,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   *  in the initializer list @a __l.
   *
   *  Note that the assignment completely changes the 
%unordered_multiset
-   *  and that the resulting %unordered_set's size is the same 
as the number
+   *  and that the resulting %unordered_multiset's size is the 
same as the number

   *  of elements assigned.  Old data may be lost.


Please reformat this to stay below 80 columns.

OK with those two tiny adjustments, thanks!






Re: [patch] libstdc++/66055 add missing constructors to unordered containers

2015-05-19 Thread Jonathan Wakely

On 17/05/15 22:21 +0200, François Dumont wrote:
Ok, I just commit fixing some other lines length except those having a 
long hyperlink, I didn't want to break those.


Yep, thanks. I think we should backport Nathan's patch and your one to
the gcc-5-branch too.

I'll make a note to do that before the 5.2 release.