From: Nathan Myers Date: Thu, 14 May 2015 13:47:19 +0000 (+0000) Subject: re PR libstdc++/66055 (hash containers missing required reserving constructors) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ddbd742bf84e7ed28d9d37d2c7b4cc9f3d7d05c0;p=gcc.git re PR libstdc++/66055 (hash containers missing required reserving constructors) 2015-05-14 Nathan Myers Jonathan Wakely 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. Co-Authored-By: Jonathan Wakely From-SVN: r223198 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 4e38fbfe93f..2311e934503 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,16 @@ +2015-05-14 Nathan Myers + Jonathan Wakely + + 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. + 2015-05-14 Jonathan Wakely PR libstdc++/66011 diff --git a/libstdc++-v3/include/bits/unordered_map.h b/libstdc++-v3/include/bits/unordered_map.h index 92b75d1dfc7..069b85922ea 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 7a2546c8257..c91eab8e113 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 00000000000..0d3e384110f --- /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 +// . + +// Jonathan Wakely + +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +#include + +using test_type = std::unordered_map; +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 00000000000..c4d68ec16da --- /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 +// . + +// Jonathan Wakely + +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +#include + +using test_type = std::unordered_multimap; +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 00000000000..0680951ebd6 --- /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 +// . + +// Jonathan Wakely + +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +#include + +using test_type = std::unordered_multiset; +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 00000000000..2ead0b1e5d1 --- /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 +// . + +// Jonathan Wakely + +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +#include + +using test_type = std::unordered_set; +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());