As an extension, support incomplete types in the unordered containers to match what we already do in the associative containers.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@146376 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d4cf215e08
commit
f8880d0b85
@ -475,7 +475,6 @@ public:
|
|||||||
public:
|
public:
|
||||||
// Create __node
|
// Create __node
|
||||||
typedef __hash_node<value_type, typename __alloc_traits::void_pointer> __node;
|
typedef __hash_node<value_type, typename __alloc_traits::void_pointer> __node;
|
||||||
typedef typename __node::__first_node __first_node;
|
|
||||||
typedef typename __alloc_traits::template
|
typedef typename __alloc_traits::template
|
||||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||||
rebind_alloc<__node>
|
rebind_alloc<__node>
|
||||||
@ -486,6 +485,7 @@ public:
|
|||||||
typedef allocator_traits<__node_allocator> __node_traits;
|
typedef allocator_traits<__node_allocator> __node_traits;
|
||||||
typedef typename __node_traits::pointer __node_pointer;
|
typedef typename __node_traits::pointer __node_pointer;
|
||||||
typedef typename __node_traits::const_pointer __node_const_pointer;
|
typedef typename __node_traits::const_pointer __node_const_pointer;
|
||||||
|
typedef __hash_node_base<__node_pointer> __first_node;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
|
|||||||
|
|
||||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||||
|
|
||||||
template <class _Tp, class _Hash, bool = is_empty<_Hash>::value
|
template <class _Key, class _Tp, class _Hash, bool = is_empty<_Hash>::value
|
||||||
#if __has_feature(is_final)
|
#if __has_feature(is_final)
|
||||||
&& !__is_final(_Hash)
|
&& !__is_final(_Hash)
|
||||||
#endif
|
#endif
|
||||||
@ -333,6 +333,8 @@ template <class _Tp, class _Hash, bool = is_empty<_Hash>::value
|
|||||||
class __unordered_map_hasher
|
class __unordered_map_hasher
|
||||||
: private _Hash
|
: private _Hash
|
||||||
{
|
{
|
||||||
|
typedef pair<typename remove_const<_Key>::type, _Tp> _Pp;
|
||||||
|
typedef pair<const _Key, _Tp> _Cp;
|
||||||
public:
|
public:
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
__unordered_map_hasher()
|
__unordered_map_hasher()
|
||||||
@ -345,17 +347,23 @@ public:
|
|||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
const _Hash& hash_function() const _NOEXCEPT {return *this;}
|
const _Hash& hash_function() const _NOEXCEPT {return *this;}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
size_t operator()(const _Tp& __x) const
|
size_t operator()(const _Pp& __x) const
|
||||||
{return static_cast<const _Hash&>(*this)(__x.first);}
|
{return static_cast<const _Hash&>(*this)(__x.first);}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
size_t operator()(const typename _Tp::first_type& __x) const
|
size_t operator()(const _Cp& __x) const
|
||||||
|
{return static_cast<const _Hash&>(*this)(__x.first);}
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
size_t operator()(const _Key& __x) const
|
||||||
{return static_cast<const _Hash&>(*this)(__x);}
|
{return static_cast<const _Hash&>(*this)(__x);}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class _Tp, class _Hash>
|
template <class _Key, class _Tp, class _Hash>
|
||||||
class __unordered_map_hasher<_Tp, _Hash, false>
|
class __unordered_map_hasher<_Key, _Tp, _Hash, false>
|
||||||
{
|
{
|
||||||
_Hash __hash_;
|
_Hash __hash_;
|
||||||
|
|
||||||
|
typedef pair<typename remove_const<_Key>::type, _Tp> _Pp;
|
||||||
|
typedef pair<const _Key, _Tp> _Cp;
|
||||||
public:
|
public:
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
__unordered_map_hasher()
|
__unordered_map_hasher()
|
||||||
@ -368,14 +376,17 @@ public:
|
|||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
const _Hash& hash_function() const _NOEXCEPT {return __hash_;}
|
const _Hash& hash_function() const _NOEXCEPT {return __hash_;}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
size_t operator()(const _Tp& __x) const
|
size_t operator()(const _Pp& __x) const
|
||||||
{return __hash_(__x.first);}
|
{return __hash_(__x.first);}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
size_t operator()(const typename _Tp::first_type& __x) const
|
size_t operator()(const _Cp& __x) const
|
||||||
|
{return __hash_(__x.first);}
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
size_t operator()(const _Key& __x) const
|
||||||
{return __hash_(__x);}
|
{return __hash_(__x);}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class _Tp, class _Pred, bool = is_empty<_Pred>::value
|
template <class _Key, class _Tp, class _Pred, bool = is_empty<_Pred>::value
|
||||||
#if __has_feature(is_final)
|
#if __has_feature(is_final)
|
||||||
&& !__is_final(_Pred)
|
&& !__is_final(_Pred)
|
||||||
#endif
|
#endif
|
||||||
@ -383,6 +394,8 @@ template <class _Tp, class _Pred, bool = is_empty<_Pred>::value
|
|||||||
class __unordered_map_equal
|
class __unordered_map_equal
|
||||||
: private _Pred
|
: private _Pred
|
||||||
{
|
{
|
||||||
|
typedef pair<typename remove_const<_Key>::type, _Tp> _Pp;
|
||||||
|
typedef pair<const _Key, _Tp> _Cp;
|
||||||
public:
|
public:
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
__unordered_map_equal()
|
__unordered_map_equal()
|
||||||
@ -395,24 +408,41 @@ public:
|
|||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
const _Pred& key_eq() const _NOEXCEPT {return *this;}
|
const _Pred& key_eq() const _NOEXCEPT {return *this;}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool operator()(const _Tp& __x, const _Tp& __y) const
|
bool operator()(const _Pp& __x, const _Pp& __y) const
|
||||||
{return static_cast<const _Pred&>(*this)(__x.first, __y.first);}
|
{return static_cast<const _Pred&>(*this)(__x.first, __y.first);}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool operator()(const typename _Tp::first_type& __x, const _Tp& __y) const
|
bool operator()(const _Pp& __x, const _Cp& __y) const
|
||||||
{return static_cast<const _Pred&>(*this)(__x, __y.first);}
|
{return static_cast<const _Pred&>(*this)(__x.first, __y.first);}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool operator()(const _Tp& __x, const typename _Tp::first_type& __y) const
|
bool operator()(const _Pp& __x, const _Key& __y) const
|
||||||
{return static_cast<const _Pred&>(*this)(__x.first, __y);}
|
{return static_cast<const _Pred&>(*this)(__x.first, __y);}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool operator()(const typename _Tp::first_type& __x,
|
bool operator()(const _Cp& __x, const _Pp& __y) const
|
||||||
const typename _Tp::first_type& __y) const
|
{return static_cast<const _Pred&>(*this)(__x.first, __y.first);}
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
bool operator()(const _Cp& __x, const _Cp& __y) const
|
||||||
|
{return static_cast<const _Pred&>(*this)(__x.first, __y.first);}
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
bool operator()(const _Cp& __x, const _Key& __y) const
|
||||||
|
{return static_cast<const _Pred&>(*this)(__x.first, __y);}
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
bool operator()(const _Key& __x, const _Pp& __y) const
|
||||||
|
{return static_cast<const _Pred&>(*this)(__x, __y.first);}
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
bool operator()(const _Key& __x, const _Cp& __y) const
|
||||||
|
{return static_cast<const _Pred&>(*this)(__x, __y.first);}
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
bool operator()(const _Key& __x, const _Key& __y) const
|
||||||
{return static_cast<const _Pred&>(*this)(__x, __y);}
|
{return static_cast<const _Pred&>(*this)(__x, __y);}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class _Tp, class _Pred>
|
template <class _Key, class _Tp, class _Pred>
|
||||||
class __unordered_map_equal<_Tp, _Pred, false>
|
class __unordered_map_equal<_Key, _Tp, _Pred, false>
|
||||||
{
|
{
|
||||||
_Pred __pred_;
|
_Pred __pred_;
|
||||||
|
|
||||||
|
typedef pair<typename remove_const<_Key>::type, _Tp> _Pp;
|
||||||
|
typedef pair<const _Key, _Tp> _Cp;
|
||||||
public:
|
public:
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
__unordered_map_equal()
|
__unordered_map_equal()
|
||||||
@ -425,17 +455,31 @@ public:
|
|||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
const _Pred& key_eq() const _NOEXCEPT {return __pred_;}
|
const _Pred& key_eq() const _NOEXCEPT {return __pred_;}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool operator()(const _Tp& __x, const _Tp& __y) const
|
bool operator()(const _Pp& __x, const _Pp& __y) const
|
||||||
{return __pred_(__x.first, __y.first);}
|
{return __pred_(__x.first, __y.first);}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool operator()(const typename _Tp::first_type& __x, const _Tp& __y) const
|
bool operator()(const _Pp& __x, const _Cp& __y) const
|
||||||
{return __pred_(__x, __y.first);}
|
{return __pred_(__x.first, __y.first);}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool operator()(const _Tp& __x, const typename _Tp::first_type& __y) const
|
bool operator()(const _Pp& __x, const _Key& __y) const
|
||||||
{return __pred_(__x.first, __y);}
|
{return __pred_(__x.first, __y);}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool operator()(const typename _Tp::first_type& __x,
|
bool operator()(const _Cp& __x, const _Pp& __y) const
|
||||||
const typename _Tp::first_type& __y) const
|
{return __pred_(__x.first, __y.first);}
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
bool operator()(const _Cp& __x, const _Cp& __y) const
|
||||||
|
{return __pred_(__x.first, __y.first);}
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
bool operator()(const _Cp& __x, const _Key& __y) const
|
||||||
|
{return __pred_(__x.first, __y);}
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
bool operator()(const _Key& __x, const _Pp& __y) const
|
||||||
|
{return __pred_(__x, __y.first);}
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
bool operator()(const _Key& __x, const _Cp& __y) const
|
||||||
|
{return __pred_(__x, __y.first);}
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
bool operator()(const _Key& __x, const _Key& __y) const
|
||||||
{return __pred_(__x, __y);}
|
{return __pred_(__x, __y);}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -632,8 +676,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
typedef pair<key_type, mapped_type> __value_type;
|
typedef pair<key_type, mapped_type> __value_type;
|
||||||
typedef __unordered_map_hasher<__value_type, hasher> __hasher;
|
typedef __unordered_map_hasher<key_type, mapped_type, hasher> __hasher;
|
||||||
typedef __unordered_map_equal<__value_type, key_equal> __key_equal;
|
typedef __unordered_map_equal<key_type, mapped_type, key_equal> __key_equal;
|
||||||
typedef typename allocator_traits<allocator_type>::template
|
typedef typename allocator_traits<allocator_type>::template
|
||||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||||
rebind_alloc<__value_type>
|
rebind_alloc<__value_type>
|
||||||
@ -1256,8 +1300,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
typedef pair<key_type, mapped_type> __value_type;
|
typedef pair<key_type, mapped_type> __value_type;
|
||||||
typedef __unordered_map_hasher<__value_type, hasher> __hasher;
|
typedef __unordered_map_hasher<key_type, mapped_type, hasher> __hasher;
|
||||||
typedef __unordered_map_equal<__value_type, key_equal> __key_equal;
|
typedef __unordered_map_equal<key_type, mapped_type, key_equal> __key_equal;
|
||||||
typedef typename allocator_traits<allocator_type>::template
|
typedef typename allocator_traits<allocator_type>::template
|
||||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||||
rebind_alloc<__value_type>
|
rebind_alloc<__value_type>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user