From 5494e5d3708b0f6337adcb9af4c2bde42b02c400 Mon Sep 17 00:00:00 2001 From: paolo Date: Thu, 22 Feb 2007 09:52:37 +0000 Subject: [PATCH] 2007-02-22 Paolo Carlini * include/tr1/unordered_map (class __unordered_map, class __unordered_multimap): New. (class unordered_map, class unordered_multimap): Forward to the latter. * include/tr1/unordered_set: Likewise for unordered_set and unordered_multiset. * testsuite/tr1/6_containers/headers/unordered_set/synopsis.cc: Remove xfail. * testsuite/tr1/6_containers/headers/unordered_map/synopsis.cc: Likewise. * testsuite/tr1/6_containers/unordered_multimap/requirements/ explicit_instantiation.cc: Adjust. * testsuite/tr1/6_containers/unordered_set/requirements/ explicit_instantiation.cc: Likewise. * testsuite/tr1/6_containers/unordered_map/requirements/ explicit_instantiation.cc: Likewise. * testsuite/tr1/6_containers/unordered_multiset/requirements/ explicit_instantiation.cc: Likewise. * testsuite/tr1/6_containers/unordered_map/24064.cc: Likewise. * testsuite/util/native_type/assoc/native_hash_set.hpp: Likewise. * testsuite/util/native_type/assoc/native_hash_map.hpp: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122223 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/include/tr1/unordered_map | 116 ++++++++++++++++----- libstdc++-v3/include/tr1/unordered_set | 116 ++++++++++++++++----- .../6_containers/headers/unordered_map/synopsis.cc | 3 +- .../6_containers/headers/unordered_set/synopsis.cc | 3 +- .../tr1/6_containers/unordered_map/24064.cc | 4 +- .../requirements/explicit_instantiation.cc | 11 +- .../requirements/explicit_instantiation.cc | 13 ++- .../requirements/explicit_instantiation.cc | 10 +- .../requirements/explicit_instantiation.cc | 10 +- .../util/native_type/assoc/native_hash_map.hpp | 4 +- .../util/native_type/assoc/native_hash_set.hpp | 8 +- 11 files changed, 221 insertions(+), 77 deletions(-) diff --git a/libstdc++-v3/include/tr1/unordered_map b/libstdc++-v3/include/tr1/unordered_map index d613d15..50e981c 100644 --- a/libstdc++-v3/include/tr1/unordered_map +++ b/libstdc++-v3/include/tr1/unordered_map @@ -48,7 +48,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) class _Pred = std::equal_to<_Key>, class _Alloc = std::allocator >, bool __cache_hash_code = false> - class unordered_map + class __unordered_map : public _Hashtable<_Key, std::pair, _Alloc, std::_Select1st >, _Pred, _Hash, __detail::_Mod_range_hashing, @@ -71,21 +71,21 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) typedef typename _Base::allocator_type allocator_type; explicit - unordered_map(size_type __n = 10, - const hasher& __hf = hasher(), - const key_equal& __eql = key_equal(), - const allocator_type& __a = allocator_type()) + __unordered_map(size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) : _Base(__n, __hf, __detail::_Mod_range_hashing(), __detail::_Default_ranged_hash(), __eql, std::_Select1st >(), __a) { } template - unordered_map(_InputIterator __f, _InputIterator __l, - size_type __n = 10, - const hasher& __hf = hasher(), - const key_equal& __eql = key_equal(), - const allocator_type& __a = allocator_type()) + __unordered_map(_InputIterator __f, _InputIterator __l, + size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) : _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(), __detail::_Default_ranged_hash(), __eql, std::_Select1st >(), __a) @@ -97,7 +97,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) class _Pred = std::equal_to<_Key>, class _Alloc = std::allocator >, bool __cache_hash_code = false> - class unordered_multimap + class __unordered_multimap : public _Hashtable<_Key, std::pair, _Alloc, std::_Select1st >, _Pred, @@ -122,10 +122,10 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) typedef typename _Base::allocator_type allocator_type; explicit - unordered_multimap(size_type __n = 10, - const hasher& __hf = hasher(), - const key_equal& __eql = key_equal(), - const allocator_type& __a = allocator_type()) + __unordered_multimap(size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) : _Base(__n, __hf, __detail::_Mod_range_hashing(), __detail::_Default_ranged_hash(), __eql, std::_Select1st >(), __a) @@ -133,11 +133,11 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) template - unordered_multimap(_InputIterator __f, _InputIterator __l, - typename _Base::size_type __n = 0, - const hasher& __hf = hasher(), - const key_equal& __eql = key_equal(), - const allocator_type& __a = allocator_type()) + __unordered_multimap(_InputIterator __f, _InputIterator __l, + typename _Base::size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) : _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(), __detail::_Default_ranged_hash(), __eql, std::_Select1st >(), __a) @@ -147,21 +147,89 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) template inline void - swap(unordered_map<_Key, _Tp, _Hash, _Pred, + swap(__unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc, __cache_hash_code>& __x, - unordered_map<_Key, _Tp, _Hash, _Pred, + __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc, __cache_hash_code>& __y) { __x.swap(__y); } template inline void - swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, + swap(__unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc, __cache_hash_code>& __x, - unordered_multimap<_Key, _Tp, _Hash, _Pred, + __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc, __cache_hash_code>& __y) { __x.swap(__y); } + + template, + class _Pred = std::equal_to<_Key>, + class _Alloc = std::allocator > > + class unordered_map + : public __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc> + { + typedef __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc> _Base; + + public: + typedef typename _Base::size_type size_type; + typedef typename _Base::hasher hasher; + typedef typename _Base::key_equal key_equal; + typedef typename _Base::allocator_type allocator_type; + + explicit + unordered_map(size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__n, __hf, __eql, __a) + { } + + template + unordered_map(_InputIterator __f, _InputIterator __l, + size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__f, __l, __n, __hf, __eql, __a) + { } + }; + + template, + class _Pred = std::equal_to<_Key>, + class _Alloc = std::allocator > > + class unordered_multimap + : public __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc> + { + typedef __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc> _Base; + + public: + typedef typename _Base::size_type size_type; + typedef typename _Base::hasher hasher; + typedef typename _Base::key_equal key_equal; + typedef typename _Base::allocator_type allocator_type; + + explicit + unordered_multimap(size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__n, __hf, __eql, __a) + { } + + + template + unordered_multimap(_InputIterator __f, _InputIterator __l, + typename _Base::size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__f, __l, __n, __hf, __eql, __a) + { } + }; + _GLIBCXX_END_NAMESPACE } diff --git a/libstdc++-v3/include/tr1/unordered_set b/libstdc++-v3/include/tr1/unordered_set index a01b89b..84a24f4 100644 --- a/libstdc++-v3/include/tr1/unordered_set +++ b/libstdc++-v3/include/tr1/unordered_set @@ -48,7 +48,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) class _Pred = std::equal_to<_Value>, class _Alloc = std::allocator<_Value>, bool __cache_hash_code = false> - class unordered_set + class __unordered_set : public _Hashtable<_Value, _Value, _Alloc, std::_Identity<_Value>, _Pred, _Hash, __detail::_Mod_range_hashing, @@ -71,21 +71,21 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) typedef typename _Base::allocator_type allocator_type; explicit - unordered_set(size_type __n = 10, - const hasher& __hf = hasher(), - const key_equal& __eql = key_equal(), - const allocator_type& __a = allocator_type()) + __unordered_set(size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) : _Base(__n, __hf, __detail::_Mod_range_hashing(), __detail::_Default_ranged_hash(), __eql, std::_Identity<_Value>(), __a) { } template - unordered_set(_InputIterator __f, _InputIterator __l, - size_type __n = 10, - const hasher& __hf = hasher(), - const key_equal& __eql = key_equal(), - const allocator_type& __a = allocator_type()) + __unordered_set(_InputIterator __f, _InputIterator __l, + size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) : _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(), __detail::_Default_ranged_hash(), __eql, std::_Identity<_Value>(), __a) @@ -97,7 +97,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) class _Pred = std::equal_to<_Value>, class _Alloc = std::allocator<_Value>, bool __cache_hash_code = false> - class unordered_multiset + class __unordered_multiset : public _Hashtable<_Value, _Value, _Alloc, std::_Identity<_Value>, _Pred, _Hash, __detail::_Mod_range_hashing, @@ -120,10 +120,10 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) typedef typename _Base::allocator_type allocator_type; explicit - unordered_multiset(size_type __n = 10, - const hasher& __hf = hasher(), - const key_equal& __eql = key_equal(), - const allocator_type& __a = allocator_type()) + __unordered_multiset(size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) : _Base(__n, __hf, __detail::_Mod_range_hashing(), __detail::_Default_ranged_hash(), __eql, std::_Identity<_Value>(), __a) @@ -131,11 +131,11 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) template - unordered_multiset(_InputIterator __f, _InputIterator __l, - typename _Base::size_type __n = 0, - const hasher& __hf = hasher(), - const key_equal& __eql = key_equal(), - const allocator_type& __a = allocator_type()) + __unordered_multiset(_InputIterator __f, _InputIterator __l, + typename _Base::size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) : _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(), __detail::_Default_ranged_hash(), __eql, std::_Identity<_Value>(), __a) @@ -145,21 +145,89 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) template inline void - swap (unordered_set<_Value, _Hash, _Pred, + swap (__unordered_set<_Value, _Hash, _Pred, _Alloc, __cache_hash_code>& __x, - unordered_set<_Value, _Hash, _Pred, + __unordered_set<_Value, _Hash, _Pred, _Alloc, __cache_hash_code>& __y) { __x.swap(__y); } template inline void - swap(unordered_multiset<_Value, _Hash, _Pred, + swap(__unordered_multiset<_Value, _Hash, _Pred, _Alloc, __cache_hash_code>& __x, - unordered_multiset<_Value, _Hash, _Pred, + __unordered_multiset<_Value, _Hash, _Pred, _Alloc, __cache_hash_code>& __y) { __x.swap(__y); } + + template, + class _Pred = std::equal_to<_Value>, + class _Alloc = std::allocator<_Value> > + class unordered_set + : public __unordered_set<_Value, _Hash, _Pred, _Alloc> + { + typedef __unordered_set<_Value, _Hash, _Pred, _Alloc> _Base; + + public: + typedef typename _Base::size_type size_type; + typedef typename _Base::hasher hasher; + typedef typename _Base::key_equal key_equal; + typedef typename _Base::allocator_type allocator_type; + + explicit + unordered_set(size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__n, __hf, __eql, __a) + { } + + template + unordered_set(_InputIterator __f, _InputIterator __l, + size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__f, __l, __n, __hf, __eql, __a) + { } + }; + + template, + class _Pred = std::equal_to<_Value>, + class _Alloc = std::allocator<_Value> > + class unordered_multiset + : public __unordered_multiset<_Value, _Hash, _Pred, _Alloc> + { + typedef __unordered_multiset<_Value, _Hash, _Pred, _Alloc> _Base; + + public: + typedef typename _Base::size_type size_type; + typedef typename _Base::hasher hasher; + typedef typename _Base::key_equal key_equal; + typedef typename _Base::allocator_type allocator_type; + + explicit + unordered_multiset(size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__n, __hf, __eql, __a) + { } + + + template + unordered_multiset(_InputIterator __f, _InputIterator __l, + typename _Base::size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__f, __l, __n, __hf, __eql, __a) + { } + }; + _GLIBCXX_END_NAMESPACE } diff --git a/libstdc++-v3/testsuite/tr1/6_containers/headers/unordered_map/synopsis.cc b/libstdc++-v3/testsuite/tr1/6_containers/headers/unordered_map/synopsis.cc index 45080fc..d54e2aa 100644 --- a/libstdc++-v3/testsuite/tr1/6_containers/headers/unordered_map/synopsis.cc +++ b/libstdc++-v3/testsuite/tr1/6_containers/headers/unordered_map/synopsis.cc @@ -1,5 +1,4 @@ -// { dg-do compile { xfail *-*-* } } -// { dg-excess-errors "" } +// { dg-do compile } // 2007-02-04 Benjamin Kosnik // diff --git a/libstdc++-v3/testsuite/tr1/6_containers/headers/unordered_set/synopsis.cc b/libstdc++-v3/testsuite/tr1/6_containers/headers/unordered_set/synopsis.cc index 29cced0..98dfc29 100644 --- a/libstdc++-v3/testsuite/tr1/6_containers/headers/unordered_set/synopsis.cc +++ b/libstdc++-v3/testsuite/tr1/6_containers/headers/unordered_set/synopsis.cc @@ -1,5 +1,4 @@ -// { dg-do compile { xfail *-*-* } } -// { dg-excess-errors "" } +// { dg-do compile } // 2007-02-04 Benjamin Kosnik // diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_map/24064.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_map/24064.cc index 74eabbf..aaacb70 100644 --- a/libstdc++-v3/testsuite/tr1/6_containers/unordered_map/24064.cc +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_map/24064.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2005 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2007 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 @@ -29,7 +29,7 @@ void test01() using namespace std; using namespace tr1; - unordered_map, equal_to, + __unordered_map, equal_to, allocator >, true> m; for (int i = 0; i < 1000; ++i) diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_map/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_map/requirements/explicit_instantiation.cc index 41ce95d..8fb0b9f 100644 --- a/libstdc++-v3/testsuite/tr1/6_containers/unordered_map/requirements/explicit_instantiation.cc +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_map/requirements/explicit_instantiation.cc @@ -2,7 +2,7 @@ // 2005-02-17 Matt Austern // -// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. +// Copyright (C) 2004, 2005, 2006, 2007 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 @@ -29,9 +29,12 @@ using namespace std; using namespace std::tr1; template class unordered_map; -template class unordered_map, equal_to, - allocator >, true>; + allocator > >; template class unordered_map, equal_to, - allocator, false>; + allocator >; +template class __unordered_map, equal_to, + allocator >, true>; diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/explicit_instantiation.cc index d48aef8..5433e0e 100644 --- a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/explicit_instantiation.cc +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/explicit_instantiation.cc @@ -2,7 +2,7 @@ // 2005-02-17 Matt Austern // -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2007 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 @@ -29,9 +29,12 @@ using namespace std; using namespace std::tr1; template class unordered_multimap; -template class unordered_multimap, equal_to, - allocator >, true>; + allocator > >; template class unordered_multimap, equal_to, - allocator, false>; + hash, equal_to, + allocator >; +template class __unordered_multimap, equal_to, + allocator >, true>; diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multiset/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multiset/requirements/explicit_instantiation.cc index 5d1e871..4389e1b 100644 --- a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multiset/requirements/explicit_instantiation.cc +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multiset/requirements/explicit_instantiation.cc @@ -2,7 +2,7 @@ // 2005-02-17 Matt Austern // -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2007 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 @@ -28,7 +28,9 @@ using namespace std; using namespace std::tr1; template class unordered_multiset; +template class unordered_multiset, equal_to, + allocator >; template class unordered_multiset, equal_to, - allocator, true>; -template class unordered_multiset, equal_to, - allocator, false>; + allocator >; +template class __unordered_multiset, equal_to, + allocator, true>; diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/explicit_instantiation.cc index ae3214f..a006abf 100644 --- a/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/explicit_instantiation.cc +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/explicit_instantiation.cc @@ -2,7 +2,7 @@ // 2005-02-17 Matt Austern // -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2007 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 @@ -28,7 +28,9 @@ using namespace std; using namespace std::tr1; template class unordered_set; +template class unordered_set, equal_to, + allocator >; template class unordered_set, equal_to, - allocator, true>; -template class unordered_set, equal_to, - allocator, false>; + allocator >; +template class __unordered_set, equal_to, + allocator, true>; diff --git a/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_map.hpp b/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_map.hpp index d6eb835..be0e8f4 100644 --- a/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_map.hpp +++ b/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_map.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2007 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 @@ -68,7 +68,7 @@ namespace pb_ds { #ifdef PB_DS_USE_TR1 #define PB_DS_BASE_C_DEC \ - std::tr1::unordered_map >::other, Cache_Hash> #else #define PB_DS_BASE_C_DEC \ diff --git a/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_set.hpp b/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_set.hpp index 7f89392..c78553b 100644 --- a/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_set.hpp +++ b/libstdc++-v3/testsuite/util/native_type/assoc/native_hash_set.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2007 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 @@ -68,12 +68,12 @@ namespace pb_ds { #ifdef PB_DS_USE_TR1 #define PB_DS_BASE_C_DEC \ - std::tr1::unordered_set::other> + std::tr1::__unordered_set::other, Cache_Hash> #else #define PB_DS_BASE_C_DEC \ __gnu_cxx::hash_set::other> + typename Allocator::template rebind::other> #endif template