public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] libstdc++/66055 add missing constructors to unordered containers
@ 2015-05-14 13:51 Jonathan Wakely
  2015-05-16 10:36 ` François Dumont
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Wakely @ 2015-05-14 13:51 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 140 bytes --]

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

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

[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 8924 bytes --]

commit f859cb0e4a369bdade09d5d77f9c8bb78d388294
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu May 14 14:36:20 2015 +0100

    2015-05-14  Nathan Myers  <ncm@cantrip.org>
    	    Jonathan Wakely  <jwakely@redhat.com>
    
    	PR libstdc++/66055
    	* include/std/unordered_map (unordered_map, unordered_multimap): Add
    	missing constructors.
    	* include/std/unordered_set (unordered_set, unordered_multiset):
    	Likewise.
    	* testsuite/23_containers/unordered_map/cons/66055.cc: New.
    	* testsuite/23_containers/unordered_multimap/cons/66055.cc: New.
    	* testsuite/23_containers/unordered_multiset/cons/66055.cc: New.
    	* testsuite/23_containers/unordered_set/cons/66055.cc: New.

diff --git a/libstdc++-v3/include/bits/unordered_map.h b/libstdc++-v3/include/bits/unordered_map.h
index 92b75d1..069b859 100644
--- a/libstdc++-v3/include/bits/unordered_map.h
+++ b/libstdc++-v3/include/bits/unordered_map.h
@@ -146,6 +146,17 @@ _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.
@@ -861,6 +872,16 @@ _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.
diff --git a/libstdc++-v3/include/bits/unordered_set.h b/libstdc++-v3/include/bits/unordered_set.h
index 7a2546c..c91eab8 100644
--- a/libstdc++-v3/include/bits/unordered_set.h
+++ b/libstdc++-v3/include/bits/unordered_set.h
@@ -140,6 +140,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       : _M_h(__n, __hf, __eql, __a)
       { }
 
+      unordered_set(size_type __n, const allocator_type& __a)
+      : _M_h(__n, hasher(), key_equal(), __a)
+      { }
+
+      unordered_set(size_type __n,
+                    const hasher& __hf,
+                    const allocator_type& __a)
+      : unordered_set(__n, __hf, key_equal(), __a)
+      { }
+
       /**
        *  @brief  Builds an %unordered_set from a range.
        *  @param  __first  An input iterator.
@@ -779,6 +789,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       : _M_h(__n, __hf, __eql, __a)
       { }
 
+      unordered_multiset(size_type __n, const allocator_type& __a)
+      : _M_h(__n, hasher(), key_equal(), __a)
+      { }
+
+      unordered_multiset(size_type __n,
+			 const hasher& __hf,
+			 const allocator_type& __a)
+      : _M_h(__n, __hf, key_equal(), __a)
+      { }
+
       /**
        *  @brief  Builds an %unordered_multiset from a range.
        *  @param  __first  An input iterator.
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/cons/66055.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/cons/66055.cc
new file mode 100644
index 0000000..0d3e384
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/cons/66055.cc
@@ -0,0 +1,30 @@
+// Copyright (C) 2015 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/>.
+
+// Jonathan Wakely  <jwakely@redhat.com>
+
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+#include <unordered_map>
+
+using test_type = std::unordered_map<int, int>;
+using hasher_type = test_type::hasher;
+using alloc_type = test_type::allocator_type;
+
+test_type h1(10, alloc_type());
+test_type h2(10, hasher_type(), alloc_type());
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/cons/66055.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/cons/66055.cc
new file mode 100644
index 0000000..c4d68ec
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/cons/66055.cc
@@ -0,0 +1,30 @@
+// Copyright (C) 2015 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/>.
+
+// Jonathan Wakely  <jwakely@redhat.com>
+
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+#include <unordered_map>
+
+using test_type = std::unordered_multimap<int, int>;
+using hasher_type = test_type::hasher;
+using alloc_type = test_type::allocator_type;
+
+test_type h1(10, alloc_type());
+test_type h2(10, hasher_type(), alloc_type());
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/cons/66055.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/cons/66055.cc
new file mode 100644
index 0000000..0680951
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/cons/66055.cc
@@ -0,0 +1,30 @@
+// Copyright (C) 2015 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/>.
+
+// Jonathan Wakely  <jwakely@redhat.com>
+
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+#include <unordered_set>
+
+using test_type = std::unordered_multiset<int>;
+using hasher_type = test_type::hasher;
+using alloc_type = test_type::allocator_type;
+
+test_type h1(10, alloc_type());
+test_type h2(10, hasher_type(), alloc_type());
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/cons/66055.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/cons/66055.cc
new file mode 100644
index 0000000..2ead0b1
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/cons/66055.cc
@@ -0,0 +1,30 @@
+// Copyright (C) 2015 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/>.
+
+// Jonathan Wakely  <jwakely@redhat.com>
+
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+#include <unordered_set>
+
+using test_type = std::unordered_set<int>;
+using hasher_type = test_type::hasher;
+using alloc_type = test_type::allocator_type;
+
+test_type h1(10, alloc_type());
+test_type h2(10, hasher_type(), alloc_type());

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-05-19 14:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-14 13:51 [patch] libstdc++/66055 add missing constructors to unordered containers Jonathan Wakely
2015-05-16 10:36 ` François Dumont
2015-05-16 19:58   ` Jonathan Wakely
2015-05-17 20:42     ` François Dumont
2015-05-19 14:33       ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).