unordered_map.h (__unordered_map): Remove.
2012-04-12 Benjamin Kosnik <bkoz@redhat.com> * include/bits/unordered_map.h (__unordered_map): Remove. (__unordered_multimap): Remove. Add aliases for __umap_traits, __umap_hashtable, __ummap_traits, __ummap_hashtable. (unordered_map): Derive from __umap_hashtable. (unordered_multimap): Derive from __ummap_hashtable. * include/bits/unordered_set.h (__unordered_set): Remove. (__unordered_multiset): Remove. Add aliases for __uset_traits, __uset_hashtable, __umset_traits, __umset_hashtable. (unordered_set): Derive from __uset_hashtable. (unordered_multiset): Derive from __umset_hashtable. * include/bits/hashtable.h (__cache_default): New, consolidated cache defaults for _Hashtable. Adjust comments for doxygen. (_Hashtable): Consolidate bool template parameters into new, _Traits class. Inherited base classes synthesize _Hashtable in CRTP via original 10 parameters. Prefer using declarations to typedefs, add __node_type, __bucket_type, etc. Push many nested types down hierarchy to _Hashtable_base. Add constructors necessary for top-level unordered_containers. Consolidate insert member functions and logic in new base class, __detail::_Insert and __detail::_Insert_base. (_Hashtable::operator=(initializer_list)): Add. * include/bits/hashtable_policy.h: Convert to doxygen markup. (_Hashtable_traits) New. Consolidate bool template parameters here. (_Insert, _Insert_base): New, consolidated insert member functions. (_Map_base, _Equality, _Rehash_base): Adjust template parameters, use base types. (_Hashtable_base): Move type declarations useful to other base classes into this class. * python/libstdcxx/v6/printers.py (Tr1HashtableIterator): Update. * testsuite/23_containers/unordered_set/instantiation_neg.cc: Adjust traits, line numbers. From-SVN: r186403
This commit is contained in:
parent
3f5c27c683
commit
4dad8b49ee
@ -1,3 +1,39 @@
|
||||
2012-04-12 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
* include/bits/unordered_map.h (__unordered_map): Remove.
|
||||
(__unordered_multimap): Remove.
|
||||
Add aliases for __umap_traits, __umap_hashtable, __ummap_traits,
|
||||
__ummap_hashtable.
|
||||
(unordered_map): Derive from __umap_hashtable.
|
||||
(unordered_multimap): Derive from __ummap_hashtable.
|
||||
* include/bits/unordered_set.h (__unordered_set): Remove.
|
||||
(__unordered_multiset): Remove.
|
||||
Add aliases for __uset_traits, __uset_hashtable, __umset_traits,
|
||||
__umset_hashtable.
|
||||
(unordered_set): Derive from __uset_hashtable.
|
||||
(unordered_multiset): Derive from __umset_hashtable.
|
||||
* include/bits/hashtable.h (__cache_default): New, consolidated
|
||||
cache defaults for _Hashtable. Adjust comments for doxygen.
|
||||
(_Hashtable): Consolidate bool template parameters into new,
|
||||
_Traits class. Inherited base classes synthesize _Hashtable in
|
||||
CRTP via original 10 parameters. Prefer using declarations to
|
||||
typedefs, add __node_type, __bucket_type, etc. Push many nested
|
||||
types down hierarchy to _Hashtable_base. Add constructors
|
||||
necessary for top-level unordered_containers. Consolidate insert
|
||||
member functions and logic in new base class, __detail::_Insert
|
||||
and __detail::_Insert_base.
|
||||
(_Hashtable::operator=(initializer_list)): Add.
|
||||
* include/bits/hashtable_policy.h: Convert to doxygen markup.
|
||||
(_Hashtable_traits) New. Consolidate bool template parameters here.
|
||||
(_Insert, _Insert_base): New, consolidated insert member functions.
|
||||
(_Map_base, _Equality, _Rehash_base): Adjust template parameters,
|
||||
use base types.
|
||||
(_Hashtable_base): Move type declarations useful to other base
|
||||
classes into this class.
|
||||
* python/libstdcxx/v6/printers.py (Tr1HashtableIterator): Update.
|
||||
* testsuite/23_containers/unordered_set/instantiation_neg.cc:
|
||||
Adjust traits, line numbers.
|
||||
|
||||
2012-04-12 Jeffrey Yasskin <jyasskin@google.com>
|
||||
|
||||
PR libstdc++/52822
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
// unordered_map implementation -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2010, 2011, 2012 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
|
||||
@ -34,208 +34,41 @@ namespace std _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
||||
|
||||
// NB: When we get typedef templates these class definitions
|
||||
// will be unnecessary.
|
||||
template<class _Key, class _Tp,
|
||||
class _Hash = hash<_Key>,
|
||||
class _Pred = std::equal_to<_Key>,
|
||||
class _Alloc = std::allocator<std::pair<const _Key, _Tp> >,
|
||||
bool __cache_hash_code =
|
||||
__not_<__and_<is_integral<_Key>, is_empty<_Hash>,
|
||||
integral_constant<bool, !__is_final(_Hash)>,
|
||||
__detail::__is_noexcept_hash<_Key, _Hash>>>::value>
|
||||
class __unordered_map
|
||||
: public _Hashtable<_Key, std::pair<const _Key, _Tp>, _Alloc,
|
||||
std::_Select1st<std::pair<const _Key, _Tp> >, _Pred,
|
||||
_Hash, __detail::_Mod_range_hashing,
|
||||
__detail::_Default_ranged_hash,
|
||||
__detail::_Prime_rehash_policy,
|
||||
__cache_hash_code, false, true>
|
||||
{
|
||||
typedef _Hashtable<_Key, std::pair<const _Key, _Tp>, _Alloc,
|
||||
std::_Select1st<std::pair<const _Key, _Tp> >, _Pred,
|
||||
_Hash, __detail::_Mod_range_hashing,
|
||||
__detail::_Default_ranged_hash,
|
||||
__detail::_Prime_rehash_policy,
|
||||
__cache_hash_code, false, true>
|
||||
_Base;
|
||||
/// Base types for unordered_map.
|
||||
template<bool _Cache>
|
||||
using __umap_traits = __detail::_Hashtable_traits<_Cache, false, true>;
|
||||
|
||||
public:
|
||||
typedef typename _Base::value_type value_type;
|
||||
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, __detail::_Mod_range_hashing(),
|
||||
__detail::_Default_ranged_hash(),
|
||||
__eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
|
||||
{ }
|
||||
|
||||
template<typename _InputIterator>
|
||||
__unordered_map(_InputIterator __f, _InputIterator __l,
|
||||
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<std::pair<const _Key, _Tp> >(), __a)
|
||||
{ }
|
||||
|
||||
__unordered_map(initializer_list<value_type> __l,
|
||||
size_type __n = 0,
|
||||
const hasher& __hf = hasher(),
|
||||
const key_equal& __eql = key_equal(),
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _Base(__l.begin(), __l.end(), __n, __hf,
|
||||
__detail::_Mod_range_hashing(),
|
||||
__detail::_Default_ranged_hash(),
|
||||
__eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
|
||||
{ }
|
||||
|
||||
__unordered_map&
|
||||
operator=(initializer_list<value_type> __l)
|
||||
{
|
||||
this->clear();
|
||||
this->insert(__l.begin(), __l.end());
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template<class _Key, class _Tp,
|
||||
class _Hash = hash<_Key>,
|
||||
class _Pred = std::equal_to<_Key>,
|
||||
class _Alloc = std::allocator<std::pair<const _Key, _Tp> >,
|
||||
bool __cache_hash_code =
|
||||
__not_<__and_<is_integral<_Key>, is_empty<_Hash>,
|
||||
integral_constant<bool, !__is_final(_Hash)>,
|
||||
__detail::__is_noexcept_hash<_Key, _Hash>>>::value>
|
||||
class __unordered_multimap
|
||||
: public _Hashtable<_Key, std::pair<const _Key, _Tp>,
|
||||
template<typename _Key,
|
||||
typename _Tp,
|
||||
typename _Hash = hash<_Key>,
|
||||
typename _Pred = std::equal_to<_Key>,
|
||||
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >,
|
||||
typename _Tr = __umap_traits<__cache_default<_Key, _Hash>::value>>
|
||||
using __umap_hashtable = _Hashtable<_Key, std::pair<const _Key, _Tp>,
|
||||
_Alloc,
|
||||
std::_Select1st<std::pair<const _Key, _Tp> >, _Pred,
|
||||
_Hash, __detail::_Mod_range_hashing,
|
||||
std::_Select1st<std::pair<const _Key, _Tp>>,
|
||||
_Pred, _Hash,
|
||||
__detail::_Mod_range_hashing,
|
||||
__detail::_Default_ranged_hash,
|
||||
__detail::_Prime_rehash_policy,
|
||||
__cache_hash_code, false, false>
|
||||
{
|
||||
typedef _Hashtable<_Key, std::pair<const _Key, _Tp>,
|
||||
__detail::_Prime_rehash_policy, _Tr>;
|
||||
|
||||
/// Base types for unordered_multimap.
|
||||
template<bool _Cache>
|
||||
using __ummap_traits = __detail::_Hashtable_traits<_Cache, false, false>;
|
||||
|
||||
template<typename _Key,
|
||||
typename _Tp,
|
||||
typename _Hash = hash<_Key>,
|
||||
typename _Pred = std::equal_to<_Key>,
|
||||
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >,
|
||||
typename _Tr = __ummap_traits<__cache_default<_Key, _Hash>::value>>
|
||||
using __ummap_hashtable = _Hashtable<_Key, std::pair<const _Key, _Tp>,
|
||||
_Alloc,
|
||||
std::_Select1st<std::pair<const _Key, _Tp> >, _Pred,
|
||||
_Hash, __detail::_Mod_range_hashing,
|
||||
std::_Select1st<std::pair<const _Key, _Tp>>,
|
||||
_Pred, _Hash,
|
||||
__detail::_Mod_range_hashing,
|
||||
__detail::_Default_ranged_hash,
|
||||
__detail::_Prime_rehash_policy,
|
||||
__cache_hash_code, false, false>
|
||||
_Base;
|
||||
|
||||
public:
|
||||
typedef typename _Base::value_type value_type;
|
||||
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, __detail::_Mod_range_hashing(),
|
||||
__detail::_Default_ranged_hash(),
|
||||
__eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
|
||||
{ }
|
||||
|
||||
|
||||
template<typename _InputIterator>
|
||||
__unordered_multimap(_InputIterator __f, _InputIterator __l,
|
||||
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<std::pair<const _Key, _Tp> >(), __a)
|
||||
{ }
|
||||
|
||||
__unordered_multimap(initializer_list<value_type> __l,
|
||||
size_type __n = 0,
|
||||
const hasher& __hf = hasher(),
|
||||
const key_equal& __eql = key_equal(),
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _Base(__l.begin(), __l.end(), __n, __hf,
|
||||
__detail::_Mod_range_hashing(),
|
||||
__detail::_Default_ranged_hash(),
|
||||
__eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
|
||||
{ }
|
||||
|
||||
__unordered_multimap&
|
||||
operator=(initializer_list<value_type> __l)
|
||||
{
|
||||
this->clear();
|
||||
this->insert(__l.begin(), __l.end());
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
|
||||
bool __cache_hash_code>
|
||||
inline void
|
||||
swap(__unordered_map<_Key, _Tp, _Hash, _Pred,
|
||||
_Alloc, __cache_hash_code>& __x,
|
||||
__unordered_map<_Key, _Tp, _Hash, _Pred,
|
||||
_Alloc, __cache_hash_code>& __y)
|
||||
{ __x.swap(__y); }
|
||||
|
||||
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
|
||||
bool __cache_hash_code>
|
||||
inline void
|
||||
swap(__unordered_multimap<_Key, _Tp, _Hash, _Pred,
|
||||
_Alloc, __cache_hash_code>& __x,
|
||||
__unordered_multimap<_Key, _Tp, _Hash, _Pred,
|
||||
_Alloc, __cache_hash_code>& __y)
|
||||
{ __x.swap(__y); }
|
||||
|
||||
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
|
||||
bool __cache_hash_code>
|
||||
inline bool
|
||||
operator==(const __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc,
|
||||
__cache_hash_code>& __x,
|
||||
const __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc,
|
||||
__cache_hash_code>& __y)
|
||||
{ return __x._M_equal(__y); }
|
||||
|
||||
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
|
||||
bool __cache_hash_code>
|
||||
inline bool
|
||||
operator!=(const __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc,
|
||||
__cache_hash_code>& __x,
|
||||
const __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc,
|
||||
__cache_hash_code>& __y)
|
||||
{ return !(__x == __y); }
|
||||
|
||||
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
|
||||
bool __cache_hash_code>
|
||||
inline bool
|
||||
operator==(const __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc,
|
||||
__cache_hash_code>& __x,
|
||||
const __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc,
|
||||
__cache_hash_code>& __y)
|
||||
{ return __x._M_equal(__y); }
|
||||
|
||||
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
|
||||
bool __cache_hash_code>
|
||||
inline bool
|
||||
operator!=(const __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc,
|
||||
__cache_hash_code>& __x,
|
||||
const __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc,
|
||||
__cache_hash_code>& __y)
|
||||
{ return !(__x == __y); }
|
||||
__detail::_Prime_rehash_policy, _Tr>;
|
||||
|
||||
/**
|
||||
* @brief A standard container composed of unique keys (containing
|
||||
@ -247,22 +80,26 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
||||
* Meets the requirements of a <a href="tables.html#65">container</a>, and
|
||||
* <a href="tables.html#xx">unordered associative container</a>
|
||||
*
|
||||
* @param Key Type of key objects.
|
||||
* @param Tp Type of mapped objects.
|
||||
* @param Hash Hashing function object type, defaults to hash<Value>.
|
||||
* @param Pred Predicate function object type, defaults to equal_to<Value>.
|
||||
* @param Alloc Allocator type, defaults to allocator<Key>.
|
||||
* @tparam _Key Type of key objects.
|
||||
* @tparam _Tp Type of mapped objects.
|
||||
* @tparam _Hash Hashing function object type, defaults to hash<_Value>.
|
||||
* @tparam _Pred Predicate function object type, defaults
|
||||
* to equal_to<_Value>.
|
||||
* @tparam _Alloc Allocator type, defaults to allocator<_Key>.
|
||||
*
|
||||
* The resulting value type of the container is std::pair<const Key, Tp>.
|
||||
* The resulting value type of the container is std::pair<const _Key, _Tp>.
|
||||
*
|
||||
* Base is _Hashtable, dispatched at compile time via template
|
||||
* alias __umap_hashtable.
|
||||
*/
|
||||
template<class _Key, class _Tp,
|
||||
class _Hash = hash<_Key>,
|
||||
class _Pred = std::equal_to<_Key>,
|
||||
class _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
|
||||
class unordered_map
|
||||
: public __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>
|
||||
: public __umap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc>
|
||||
{
|
||||
typedef __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc> _Base;
|
||||
typedef __umap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Base;
|
||||
|
||||
public:
|
||||
typedef typename _Base::value_type value_type;
|
||||
@ -295,14 +132,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a)
|
||||
{ }
|
||||
|
||||
unordered_map&
|
||||
operator=(initializer_list<value_type> __l)
|
||||
{
|
||||
this->clear();
|
||||
this->insert(__l.begin(), __l.end());
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -315,22 +144,26 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
||||
* Meets the requirements of a <a href="tables.html#65">container</a>, and
|
||||
* <a href="tables.html#xx">unordered associative container</a>
|
||||
*
|
||||
* @param Key Type of key objects.
|
||||
* @param Tp Type of mapped objects.
|
||||
* @param Hash Hashing function object type, defaults to hash<Value>.
|
||||
* @param Pred Predicate function object type, defaults to equal_to<Value>.
|
||||
* @param Alloc Allocator type, defaults to allocator<Key>.
|
||||
* @tparam _Key Type of key objects.
|
||||
* @tparam _Tp Type of mapped objects.
|
||||
* @tparam _Hash Hashing function object type, defaults to hash<_Value>.
|
||||
* @tparam _Pred Predicate function object type, defaults
|
||||
* to equal_to<_Value>.
|
||||
* @tparam _Alloc Allocator type, defaults to allocator<_Key>.
|
||||
*
|
||||
* The resulting value type of the container is std::pair<const Key, Tp>.
|
||||
* The resulting value type of the container is std::pair<const _Key, _Tp>.
|
||||
*
|
||||
* Base is _Hashtable, dispatched at compile time via template
|
||||
* alias __ummap_hashtable.
|
||||
*/
|
||||
template<class _Key, class _Tp,
|
||||
class _Hash = hash<_Key>,
|
||||
class _Pred = std::equal_to<_Key>,
|
||||
class _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
|
||||
class unordered_multimap
|
||||
: public __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>
|
||||
: public __ummap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc>
|
||||
{
|
||||
typedef __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc> _Base;
|
||||
typedef __ummap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Base;
|
||||
|
||||
public:
|
||||
typedef typename _Base::value_type value_type;
|
||||
@ -363,14 +196,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a)
|
||||
{ }
|
||||
|
||||
unordered_multimap&
|
||||
operator=(initializer_list<value_type> __l)
|
||||
{
|
||||
this->clear();
|
||||
this->insert(__l.begin(), __l.end());
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// unordered_set implementation -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2010, 2011, 2012 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
|
||||
@ -34,228 +34,36 @@ namespace std _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
||||
|
||||
// NB: When we get typedef templates these class definitions
|
||||
// will be unnecessary.
|
||||
template<class _Value,
|
||||
class _Hash = hash<_Value>,
|
||||
class _Pred = std::equal_to<_Value>,
|
||||
class _Alloc = std::allocator<_Value>,
|
||||
bool __cache_hash_code =
|
||||
__not_<__and_<is_integral<_Value>, is_empty<_Hash>,
|
||||
integral_constant<bool, !__is_final(_Hash)>,
|
||||
__detail::__is_noexcept_hash<_Value, _Hash>>>::value>
|
||||
class __unordered_set
|
||||
: public _Hashtable<_Value, _Value, _Alloc,
|
||||
std::_Identity<_Value>, _Pred,
|
||||
_Hash, __detail::_Mod_range_hashing,
|
||||
/// Base types for unordered_set.
|
||||
template<bool _Cache>
|
||||
using __uset_traits = __detail::_Hashtable_traits<_Cache, true, true>;
|
||||
|
||||
template<typename _Value,
|
||||
typename _Hash = hash<_Value>,
|
||||
typename _Pred = std::equal_to<_Value>,
|
||||
typename _Alloc = std::allocator<_Value>,
|
||||
typename _Tr = __uset_traits<__cache_default<_Value, _Hash>::value>>
|
||||
using __uset_hashtable = _Hashtable<_Value, _Value, _Alloc,
|
||||
std::_Identity<_Value>, _Pred, _Hash,
|
||||
__detail::_Mod_range_hashing,
|
||||
__detail::_Default_ranged_hash,
|
||||
__detail::_Prime_rehash_policy,
|
||||
__cache_hash_code, true, true>
|
||||
{
|
||||
typedef _Hashtable<_Value, _Value, _Alloc,
|
||||
std::_Identity<_Value>, _Pred,
|
||||
_Hash, __detail::_Mod_range_hashing,
|
||||
__detail::_Prime_rehash_policy, _Tr>;
|
||||
|
||||
/// Base types for unordered_multiset.
|
||||
template<bool _Cache>
|
||||
using __umset_traits = __detail::_Hashtable_traits<_Cache, true, false>;
|
||||
|
||||
template<typename _Value,
|
||||
typename _Hash = hash<_Value>,
|
||||
typename _Pred = std::equal_to<_Value>,
|
||||
typename _Alloc = std::allocator<_Value>,
|
||||
typename _Tr = __umset_traits<__cache_default<_Value, _Hash>::value>>
|
||||
using __umset_hashtable = _Hashtable<_Value, _Value, _Alloc,
|
||||
std::_Identity<_Value>,
|
||||
_Pred, _Hash,
|
||||
__detail::_Mod_range_hashing,
|
||||
__detail::_Default_ranged_hash,
|
||||
__detail::_Prime_rehash_policy,
|
||||
__cache_hash_code, true, true>
|
||||
_Base;
|
||||
|
||||
public:
|
||||
typedef typename _Base::value_type value_type;
|
||||
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;
|
||||
typedef typename _Base::iterator iterator;
|
||||
typedef typename _Base::const_iterator const_iterator;
|
||||
|
||||
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, __detail::_Mod_range_hashing(),
|
||||
__detail::_Default_ranged_hash(), __eql,
|
||||
std::_Identity<value_type>(), __a)
|
||||
{ }
|
||||
|
||||
template<typename _InputIterator>
|
||||
__unordered_set(_InputIterator __f, _InputIterator __l,
|
||||
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_type>(), __a)
|
||||
{ }
|
||||
|
||||
__unordered_set(initializer_list<value_type> __l,
|
||||
size_type __n = 0,
|
||||
const hasher& __hf = hasher(),
|
||||
const key_equal& __eql = key_equal(),
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _Base(__l.begin(), __l.end(), __n, __hf,
|
||||
__detail::_Mod_range_hashing(),
|
||||
__detail::_Default_ranged_hash(), __eql,
|
||||
std::_Identity<value_type>(), __a)
|
||||
{ }
|
||||
|
||||
__unordered_set&
|
||||
operator=(initializer_list<value_type> __l)
|
||||
{
|
||||
this->clear();
|
||||
this->insert(__l.begin(), __l.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
using _Base::insert;
|
||||
|
||||
std::pair<iterator, bool>
|
||||
insert(value_type&& __v)
|
||||
{ return this->_M_insert(std::move(__v), std::true_type()); }
|
||||
|
||||
iterator
|
||||
insert(const_iterator, value_type&& __v)
|
||||
{ return insert(std::move(__v)).first; }
|
||||
};
|
||||
|
||||
template<class _Value,
|
||||
class _Hash = hash<_Value>,
|
||||
class _Pred = std::equal_to<_Value>,
|
||||
class _Alloc = std::allocator<_Value>,
|
||||
bool __cache_hash_code =
|
||||
__not_<__and_<is_integral<_Value>, is_empty<_Hash>,
|
||||
integral_constant<bool, !__is_final(_Hash)>,
|
||||
__detail::__is_noexcept_hash<_Value, _Hash>>>::value>
|
||||
class __unordered_multiset
|
||||
: public _Hashtable<_Value, _Value, _Alloc,
|
||||
std::_Identity<_Value>, _Pred,
|
||||
_Hash, __detail::_Mod_range_hashing,
|
||||
__detail::_Default_ranged_hash,
|
||||
__detail::_Prime_rehash_policy,
|
||||
__cache_hash_code, true, false>
|
||||
{
|
||||
typedef _Hashtable<_Value, _Value, _Alloc,
|
||||
std::_Identity<_Value>, _Pred,
|
||||
_Hash, __detail::_Mod_range_hashing,
|
||||
__detail::_Default_ranged_hash,
|
||||
__detail::_Prime_rehash_policy,
|
||||
__cache_hash_code, true, false>
|
||||
_Base;
|
||||
|
||||
public:
|
||||
typedef typename _Base::value_type value_type;
|
||||
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;
|
||||
typedef typename _Base::iterator iterator;
|
||||
typedef typename _Base::const_iterator const_iterator;
|
||||
|
||||
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, __detail::_Mod_range_hashing(),
|
||||
__detail::_Default_ranged_hash(), __eql,
|
||||
std::_Identity<value_type>(), __a)
|
||||
{ }
|
||||
|
||||
|
||||
template<typename _InputIterator>
|
||||
__unordered_multiset(_InputIterator __f, _InputIterator __l,
|
||||
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_type>(), __a)
|
||||
{ }
|
||||
|
||||
__unordered_multiset(initializer_list<value_type> __l,
|
||||
size_type __n = 0,
|
||||
const hasher& __hf = hasher(),
|
||||
const key_equal& __eql = key_equal(),
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _Base(__l.begin(), __l.end(), __n, __hf,
|
||||
__detail::_Mod_range_hashing(),
|
||||
__detail::_Default_ranged_hash(), __eql,
|
||||
std::_Identity<value_type>(), __a)
|
||||
{ }
|
||||
|
||||
__unordered_multiset&
|
||||
operator=(initializer_list<value_type> __l)
|
||||
{
|
||||
this->clear();
|
||||
this->insert(__l.begin(), __l.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
using _Base::insert;
|
||||
|
||||
iterator
|
||||
insert(value_type&& __v)
|
||||
{ return this->_M_insert(std::move(__v), std::false_type()); }
|
||||
|
||||
iterator
|
||||
insert(const_iterator, value_type&& __v)
|
||||
{ return insert(std::move(__v)); }
|
||||
};
|
||||
|
||||
template<class _Value, class _Hash, class _Pred, class _Alloc,
|
||||
bool __cache_hash_code>
|
||||
inline void
|
||||
swap(__unordered_set<_Value, _Hash, _Pred, _Alloc, __cache_hash_code>& __x,
|
||||
__unordered_set<_Value, _Hash, _Pred, _Alloc, __cache_hash_code>& __y)
|
||||
{ __x.swap(__y); }
|
||||
|
||||
template<class _Value, class _Hash, class _Pred, class _Alloc,
|
||||
bool __cache_hash_code>
|
||||
inline void
|
||||
swap(__unordered_multiset<_Value, _Hash, _Pred,
|
||||
_Alloc, __cache_hash_code>& __x,
|
||||
__unordered_multiset<_Value, _Hash, _Pred,
|
||||
_Alloc, __cache_hash_code>& __y)
|
||||
{ __x.swap(__y); }
|
||||
|
||||
template<class _Value, class _Hash, class _Pred, class _Alloc,
|
||||
bool __cache_hash_code>
|
||||
inline bool
|
||||
operator==(const __unordered_set<_Value, _Hash, _Pred, _Alloc,
|
||||
__cache_hash_code>& __x,
|
||||
const __unordered_set<_Value, _Hash, _Pred, _Alloc,
|
||||
__cache_hash_code>& __y)
|
||||
{ return __x._M_equal(__y); }
|
||||
|
||||
template<class _Value, class _Hash, class _Pred, class _Alloc,
|
||||
bool __cache_hash_code>
|
||||
inline bool
|
||||
operator!=(const __unordered_set<_Value, _Hash, _Pred, _Alloc,
|
||||
__cache_hash_code>& __x,
|
||||
const __unordered_set<_Value, _Hash, _Pred, _Alloc,
|
||||
__cache_hash_code>& __y)
|
||||
{ return !(__x == __y); }
|
||||
|
||||
template<class _Value, class _Hash, class _Pred, class _Alloc,
|
||||
bool __cache_hash_code>
|
||||
inline bool
|
||||
operator==(const __unordered_multiset<_Value, _Hash, _Pred, _Alloc,
|
||||
__cache_hash_code>& __x,
|
||||
const __unordered_multiset<_Value, _Hash, _Pred, _Alloc,
|
||||
__cache_hash_code>& __y)
|
||||
{ return __x._M_equal(__y); }
|
||||
|
||||
template<class _Value, class _Hash, class _Pred, class _Alloc,
|
||||
bool __cache_hash_code>
|
||||
inline bool
|
||||
operator!=(const __unordered_multiset<_Value, _Hash, _Pred, _Alloc,
|
||||
__cache_hash_code>& __x,
|
||||
const __unordered_multiset<_Value, _Hash, _Pred, _Alloc,
|
||||
__cache_hash_code>& __y)
|
||||
{ return !(__x == __y); }
|
||||
__detail::_Prime_rehash_policy, _Tr>;
|
||||
|
||||
/**
|
||||
* @brief A standard container composed of unique keys (containing
|
||||
@ -267,19 +75,25 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
||||
* Meets the requirements of a <a href="tables.html#65">container</a>, and
|
||||
* <a href="tables.html#xx">unordered associative container</a>
|
||||
*
|
||||
* @param Value Type of key objects.
|
||||
* @param Hash Hashing function object type, defaults to hash<Value>.
|
||||
* @param Pred Predicate function object type, defaults to equal_to<Value>.
|
||||
* @param Alloc Allocator type, defaults to allocator<Key>.
|
||||
* @tparam _Value Type of key objects.
|
||||
* @tparam _Hash Hashing function object type, defaults to hash<_Value>.
|
||||
|
||||
* @tparam _Pred Predicate function object type, defaults to
|
||||
* equal_to<_Value>.
|
||||
*
|
||||
* @tparam _Alloc Allocator type, defaults to allocator<_Key>.
|
||||
*
|
||||
* Base is _Hashtable, dispatched at compile time via template
|
||||
* alias __uset_hashtable.
|
||||
*/
|
||||
template<class _Value,
|
||||
class _Hash = hash<_Value>,
|
||||
class _Pred = std::equal_to<_Value>,
|
||||
class _Alloc = std::allocator<_Value> >
|
||||
class unordered_set
|
||||
: public __unordered_set<_Value, _Hash, _Pred, _Alloc>
|
||||
: public __uset_hashtable<_Value, _Hash, _Pred, _Alloc>
|
||||
{
|
||||
typedef __unordered_set<_Value, _Hash, _Pred, _Alloc> _Base;
|
||||
typedef __uset_hashtable<_Value, _Hash, _Pred, _Alloc> _Base;
|
||||
|
||||
public:
|
||||
typedef typename _Base::value_type value_type;
|
||||
@ -312,14 +126,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a)
|
||||
{ }
|
||||
|
||||
unordered_set&
|
||||
operator=(initializer_list<value_type> __l)
|
||||
{
|
||||
this->clear();
|
||||
this->insert(__l.begin(), __l.end());
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -332,19 +138,23 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
||||
* Meets the requirements of a <a href="tables.html#65">container</a>, and
|
||||
* <a href="tables.html#xx">unordered associative container</a>
|
||||
*
|
||||
* @param Value Type of key objects.
|
||||
* @param Hash Hashing function object type, defaults to hash<Value>.
|
||||
* @param Pred Predicate function object type, defaults to equal_to<Value>.
|
||||
* @param Alloc Allocator type, defaults to allocator<Key>.
|
||||
* @tparam _Value Type of key objects.
|
||||
* @tparam _Hash Hashing function object type, defaults to hash<_Value>.
|
||||
* @tparam _Pred Predicate function object type, defaults
|
||||
* to equal_to<_Value>.
|
||||
* @tparam _Alloc Allocator type, defaults to allocator<_Key>.
|
||||
*
|
||||
* Base is _Hashtable, dispatched at compile time via template
|
||||
* alias __umset_hashtable.
|
||||
*/
|
||||
template<class _Value,
|
||||
class _Hash = hash<_Value>,
|
||||
class _Pred = std::equal_to<_Value>,
|
||||
class _Alloc = std::allocator<_Value> >
|
||||
class unordered_multiset
|
||||
: public __unordered_multiset<_Value, _Hash, _Pred, _Alloc>
|
||||
: public __umset_hashtable<_Value, _Hash, _Pred, _Alloc>
|
||||
{
|
||||
typedef __unordered_multiset<_Value, _Hash, _Pred, _Alloc> _Base;
|
||||
typedef __umset_hashtable<_Value, _Hash, _Pred, _Alloc> _Base;
|
||||
|
||||
public:
|
||||
typedef typename _Base::value_type value_type;
|
||||
@ -378,14 +188,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a)
|
||||
{ }
|
||||
|
||||
unordered_multiset&
|
||||
operator=(initializer_list<value_type> __l)
|
||||
{
|
||||
this->clear();
|
||||
this->insert(__l.begin(), __l.end());
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template<class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
@ -428,4 +230,3 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
|
||||
} // namespace std
|
||||
|
||||
#endif /* _UNORDERED_SET_H */
|
||||
|
||||
|
@ -611,7 +611,7 @@ class StdStringPrinter:
|
||||
class Tr1HashtableIterator:
|
||||
def __init__ (self, hash):
|
||||
self.node = hash['_M_before_begin']['_M_nxt']
|
||||
self.node_type = find_type(hash.type, '_Node').pointer()
|
||||
self.node_type = find_type(hash.type, '__node_type').pointer()
|
||||
|
||||
def __iter__ (self):
|
||||
return self
|
||||
|
@ -2,7 +2,7 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-require-normal-mode "" }
|
||||
|
||||
// Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2011, 2012 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
|
||||
@ -19,7 +19,7 @@
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-error "static assertion failed" "" { target *-*-* } 185 }
|
||||
// { dg-error "with noexcept" "" { target *-*-* } 248 }
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
@ -35,7 +35,10 @@ namespace
|
||||
void
|
||||
test01()
|
||||
{
|
||||
std::__unordered_set<int, hash_without_noexcept,
|
||||
std::equal_to<int>, std::allocator<int>,
|
||||
false> us;
|
||||
using traits = std::__detail::_Hashtable_traits<false, true, true>;
|
||||
using hashtable = std::__uset_hashtable<int, hash_without_noexcept,
|
||||
std::equal_to<int>,
|
||||
std::allocator<int>, traits>;
|
||||
|
||||
hashtable ht;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user