forked from OSchip/llvm-project
[libc++] [P0919] Some belated review on D87171.
- Simplify the structure of the new tests. - Test const containers as well as non-const containers, since it's easy to do so. - Remove redundant enable-iffing of helper structs' member functions. (They're not instantiated unless they're called, and who would call them?) - Fix indentation and use more consistent SFINAE method in <unordered_map>. - Add _LIBCPP_INLINE_VISIBILITY on some swap functions. Differential Revision: https://reviews.llvm.org/D109011
This commit is contained in:
parent
df81bb71aa
commit
d5db71d19f
|
@ -545,15 +545,13 @@ public:
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
template <typename _K2>
|
template <typename _K2>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
|
bool operator()(const _K2& __x, const _CP& __y) const
|
||||||
operator () ( const _K2& __x, const _CP& __y ) const
|
{return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);}
|
||||||
{return static_cast<const _Compare&>(*this) (__x, __y.__get_value().first);}
|
|
||||||
|
|
||||||
template <typename _K2>
|
template <typename _K2>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
|
bool operator()(const _CP& __x, const _K2& __y) const
|
||||||
operator () (const _CP& __x, const _K2& __y) const
|
{return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y);}
|
||||||
{return static_cast<const _Compare&>(*this) (__x.__get_value().first, __y);}
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -593,15 +591,13 @@ public:
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
template <typename _K2>
|
template <typename _K2>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
|
bool operator()(const _K2& __x, const _CP& __y) const
|
||||||
operator () ( const _K2& __x, const _CP& __y ) const
|
{return comp(__x, __y.__get_value().first);}
|
||||||
{return comp (__x, __y.__get_value().first);}
|
|
||||||
|
|
||||||
template <typename _K2>
|
template <typename _K2>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
|
bool operator()(const _CP& __x, const _K2& __y) const
|
||||||
operator () (const _CP& __x, const _K2& __y) const
|
{return comp(__x.__get_value().first, __y);}
|
||||||
{return comp (__x.__get_value().first, __y);}
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -473,11 +473,12 @@ public:
|
||||||
size_t operator()(const _Key& __x) const
|
size_t operator()(const _Key& __x) const
|
||||||
{return static_cast<const _Hash&>(*this)(__x);}
|
{return static_cast<const _Hash&>(*this)(__x);}
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
template <typename _K2, typename = enable_if_t<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
|
template <typename _K2>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
size_t operator()(const _K2& __x) const
|
size_t operator()(const _K2& __x) const
|
||||||
{return static_cast<const _Hash&>(*this)(__x);}
|
{return static_cast<const _Hash&>(*this)(__x);}
|
||||||
#endif
|
#endif
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
void swap(__unordered_map_hasher& __y)
|
void swap(__unordered_map_hasher& __y)
|
||||||
_NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
|
_NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
|
||||||
{
|
{
|
||||||
|
@ -508,11 +509,12 @@ public:
|
||||||
size_t operator()(const _Key& __x) const
|
size_t operator()(const _Key& __x) const
|
||||||
{return __hash_(__x);}
|
{return __hash_(__x);}
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
template <typename _K2, typename = enable_if_t<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
|
template <typename _K2>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
size_t operator()(const _K2& __x) const
|
size_t operator()(const _K2& __x) const
|
||||||
{return __hash_(__x);}
|
{return __hash_(__x);}
|
||||||
#endif
|
#endif
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
void swap(__unordered_map_hasher& __y)
|
void swap(__unordered_map_hasher& __y)
|
||||||
_NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
|
_NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
|
||||||
{
|
{
|
||||||
|
@ -557,23 +559,24 @@ public:
|
||||||
bool operator()(const _Key& __x, const _Cp& __y) const
|
bool operator()(const _Key& __x, const _Cp& __y) const
|
||||||
{return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);}
|
{return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);}
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
template <typename _K2, typename = enable_if_t<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
|
template <typename _K2>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool operator()(const _Cp& __x, const _K2& __y) const
|
bool operator()(const _Cp& __x, const _K2& __y) const
|
||||||
{return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);}
|
{return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);}
|
||||||
template <typename _K2, typename = enable_if_t<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
|
template <typename _K2>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool operator()(const _K2& __x, const _Cp& __y) const
|
bool operator()(const _K2& __x, const _Cp& __y) const
|
||||||
{return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);}
|
{return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);}
|
||||||
template <typename _K2, typename = enable_if_t<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
|
template <typename _K2>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool operator()(const _Key& __x, const _K2& __y) const
|
bool operator()(const _Key& __x, const _K2& __y) const
|
||||||
{return static_cast<const _Pred&>(*this)(__x, __y);}
|
{return static_cast<const _Pred&>(*this)(__x, __y);}
|
||||||
template <typename _K2, typename = enable_if_t<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
|
template <typename _K2>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool operator()(const _K2& __x, const _Key& __y) const
|
bool operator()(const _K2& __x, const _Key& __y) const
|
||||||
{return static_cast<const _Pred&>(*this)(__x, __y);}
|
{return static_cast<const _Pred&>(*this)(__x, __y);}
|
||||||
#endif
|
#endif
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
void swap(__unordered_map_equal& __y)
|
void swap(__unordered_map_equal& __y)
|
||||||
_NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
|
_NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
|
||||||
{
|
{
|
||||||
|
@ -607,23 +610,24 @@ public:
|
||||||
bool operator()(const _Key& __x, const _Cp& __y) const
|
bool operator()(const _Key& __x, const _Cp& __y) const
|
||||||
{return __pred_(__x, __y.__get_value().first);}
|
{return __pred_(__x, __y.__get_value().first);}
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
template <typename _K2, typename = enable_if_t<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
|
template <typename _K2>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool operator()(const _Cp& __x, const _K2& __y) const
|
bool operator()(const _Cp& __x, const _K2& __y) const
|
||||||
{return __pred_(__x.__get_value().first, __y);}
|
{return __pred_(__x.__get_value().first, __y);}
|
||||||
template <typename _K2, typename = enable_if_t<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
|
template <typename _K2>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool operator()(const _K2& __x, const _Cp& __y) const
|
bool operator()(const _K2& __x, const _Cp& __y) const
|
||||||
{return __pred_(__x, __y.__get_value().first);}
|
{return __pred_(__x, __y.__get_value().first);}
|
||||||
template <typename _K2, typename = enable_if_t<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
|
template <typename _K2>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool operator()(const _Key& __x, const _K2& __y) const
|
bool operator()(const _Key& __x, const _K2& __y) const
|
||||||
{return __pred_(__x, __y);}
|
{return __pred_(__x, __y);}
|
||||||
template <typename _K2, typename = enable_if_t<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>>
|
template <typename _K2>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool operator()(const _K2& __x, const _Key& __y) const
|
bool operator()(const _K2& __x, const _Key& __y) const
|
||||||
{return __pred_(__x, __y);}
|
{return __pred_(__x, __y);}
|
||||||
#endif
|
#endif
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
void swap(__unordered_map_equal& __y)
|
void swap(__unordered_map_equal& __y)
|
||||||
_NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
|
_NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
|
||||||
{
|
{
|
||||||
|
@ -1355,51 +1359,48 @@ public:
|
||||||
iterator find(const key_type& __k) {return __table_.find(__k);}
|
iterator find(const key_type& __k) {return __table_.find(__k);}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
|
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
|
||||||
|
#if _LIBCPP_STD_VER > 17
|
||||||
#if _LIBCPP_STD_VER > 17
|
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
template <typename _K2>
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
iterator find(const _K2& __k) {return __table_.find(__k);}
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator>
|
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
find(const _K2& __k) {return __table_.find(__k);}
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
template <typename _K2>
|
const_iterator find(const _K2& __k) const {return __table_.find(__k);}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
#endif // _LIBCPP_STD_VER > 17
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator>
|
|
||||||
find(const _K2& __k) const {return __table_.find(__k);}
|
|
||||||
#endif // _LIBCPP_STD_VER > 17
|
|
||||||
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
|
size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
template <typename _K2>
|
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type>
|
size_type count(const _K2& __k) const {return __table_.__count_unique(__k);}
|
||||||
count(const _K2& __k) const {return __table_.__count_unique(__k);}
|
#endif // _LIBCPP_STD_VER > 17
|
||||||
#endif // _LIBCPP_STD_VER > 17
|
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool contains(const key_type& __k) const {return find(__k) != end();}
|
bool contains(const key_type& __k) const {return find(__k) != end();}
|
||||||
|
|
||||||
|
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
bool contains(const _K2& __k) const {return find(__k) != end();}
|
||||||
|
#endif // _LIBCPP_STD_VER > 17
|
||||||
|
|
||||||
template <typename _K2>
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool>
|
|
||||||
contains(const _K2& __k) const {return find(__k) != end();}
|
|
||||||
#endif // _LIBCPP_STD_VER > 17
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
pair<iterator, iterator> equal_range(const key_type& __k)
|
pair<iterator, iterator> equal_range(const key_type& __k)
|
||||||
{return __table_.__equal_range_unique(__k);}
|
{return __table_.__equal_range_unique(__k);}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
|
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
|
||||||
{return __table_.__equal_range_unique(__k);}
|
{return __table_.__equal_range_unique(__k);}
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
template <typename _K2>
|
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>>
|
pair<iterator, iterator> equal_range(const _K2& __k)
|
||||||
equal_range(const _K2& __k) {return __table_.__equal_range_unique(__k);}
|
{return __table_.__equal_range_unique(__k);}
|
||||||
template <typename _K2>
|
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>>
|
pair<const_iterator, const_iterator> equal_range(const _K2& __k) const
|
||||||
equal_range(const _K2& __k) const {return __table_.__equal_range_unique(__k);}
|
{return __table_.__equal_range_unique(__k);}
|
||||||
#endif // _LIBCPP_STD_VER > 17
|
#endif // _LIBCPP_STD_VER > 17
|
||||||
|
|
||||||
mapped_type& operator[](const key_type& __k);
|
mapped_type& operator[](const key_type& __k);
|
||||||
#ifndef _LIBCPP_CXX03_LANG
|
#ifndef _LIBCPP_CXX03_LANG
|
||||||
|
@ -2167,49 +2168,48 @@ public:
|
||||||
iterator find(const key_type& __k) {return __table_.find(__k);}
|
iterator find(const key_type& __k) {return __table_.find(__k);}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
|
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
template <typename _K2>
|
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator>
|
iterator find(const _K2& __k) {return __table_.find(__k);}
|
||||||
find(const _K2& __k) {return __table_.find(__k);}
|
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
template <typename _K2>
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
const_iterator find(const _K2& __k) const {return __table_.find(__k);}
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator>
|
#endif // _LIBCPP_STD_VER > 17
|
||||||
find(const _K2& __k) const {return __table_.find(__k);}
|
|
||||||
#endif // _LIBCPP_STD_VER > 17
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
|
size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
template <typename _K2>
|
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type>
|
size_type count(const _K2& __k) const {return __table_.__count_multi(__k);}
|
||||||
count(const _K2& __k) const {return __table_.__count_multi(__k);}
|
#endif // _LIBCPP_STD_VER > 17
|
||||||
#endif // _LIBCPP_STD_VER > 17
|
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool contains(const key_type& __k) const {return find(__k) != end();}
|
bool contains(const key_type& __k) const {return find(__k) != end();}
|
||||||
|
|
||||||
|
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
bool contains(const _K2& __k) const {return find(__k) != end();}
|
||||||
|
#endif // _LIBCPP_STD_VER > 17
|
||||||
|
|
||||||
template <typename _K2>
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool>
|
|
||||||
contains(const _K2& __k) const {return find(__k) != end();}
|
|
||||||
#endif // _LIBCPP_STD_VER > 17
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
pair<iterator, iterator> equal_range(const key_type& __k)
|
pair<iterator, iterator> equal_range(const key_type& __k)
|
||||||
{return __table_.__equal_range_multi(__k);}
|
{return __table_.__equal_range_multi(__k);}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
|
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
|
||||||
{return __table_.__equal_range_multi(__k);}
|
{return __table_.__equal_range_multi(__k);}
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
template <typename _K2>
|
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>>
|
pair<iterator, iterator> equal_range(const _K2& __k)
|
||||||
equal_range(const _K2& __k) {return __table_.__equal_range_multi(__k);}
|
{return __table_.__equal_range_multi(__k);}
|
||||||
template <typename _K2>
|
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>>
|
pair<const_iterator, const_iterator> equal_range(const _K2& __k) const
|
||||||
equal_range(const _K2& __k) const {return __table_.__equal_range_multi(__k);}
|
{return __table_.__equal_range_multi(__k);}
|
||||||
#endif // _LIBCPP_STD_VER > 17
|
#endif // _LIBCPP_STD_VER > 17
|
||||||
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
|
size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
|
||||||
|
|
|
@ -706,49 +706,48 @@ public:
|
||||||
iterator find(const key_type& __k) {return __table_.find(__k);}
|
iterator find(const key_type& __k) {return __table_.find(__k);}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
|
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
template <typename _K2>
|
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator>
|
iterator find(const _K2& __k) {return __table_.find(__k);}
|
||||||
find(const _K2& __k) {return __table_.find(__k);}
|
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
template <typename _K2>
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
const_iterator find(const _K2& __k) const {return __table_.find(__k);}
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator>
|
#endif // _LIBCPP_STD_VER > 17
|
||||||
find(const _K2& __k) const {return __table_.find(__k);}
|
|
||||||
#endif // _LIBCPP_STD_VER > 17
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
|
size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
template <typename _K2>
|
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type>
|
size_type count(const _K2& __k) const {return __table_.__count_unique(__k);}
|
||||||
count(const _K2& __k) const {return __table_.__count_unique(__k);}
|
#endif // _LIBCPP_STD_VER > 17
|
||||||
#endif // _LIBCPP_STD_VER > 17
|
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool contains(const key_type& __k) const {return find(__k) != end();}
|
bool contains(const key_type& __k) const {return find(__k) != end();}
|
||||||
|
|
||||||
|
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
bool contains(const _K2& __k) const {return find(__k) != end();}
|
||||||
|
#endif // _LIBCPP_STD_VER > 17
|
||||||
|
|
||||||
template <typename _K2>
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool>
|
|
||||||
contains(const _K2& __k) const {return find(__k) != end();}
|
|
||||||
#endif // _LIBCPP_STD_VER > 17
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
pair<iterator, iterator> equal_range(const key_type& __k)
|
pair<iterator, iterator> equal_range(const key_type& __k)
|
||||||
{return __table_.__equal_range_unique(__k);}
|
{return __table_.__equal_range_unique(__k);}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
|
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
|
||||||
{return __table_.__equal_range_unique(__k);}
|
{return __table_.__equal_range_unique(__k);}
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
template <typename _K2>
|
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>>
|
pair<iterator, iterator> equal_range(const _K2& __k)
|
||||||
equal_range(const _K2& __k) {return __table_.__equal_range_unique(__k);}
|
{return __table_.__equal_range_unique(__k);}
|
||||||
template <typename _K2>
|
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>>
|
pair<const_iterator, const_iterator> equal_range(const _K2& __k) const
|
||||||
equal_range(const _K2& __k) const {return __table_.__equal_range_unique(__k);}
|
{return __table_.__equal_range_unique(__k);}
|
||||||
#endif // _LIBCPP_STD_VER > 17
|
#endif // _LIBCPP_STD_VER > 17
|
||||||
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
|
size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
|
||||||
|
@ -1372,49 +1371,48 @@ public:
|
||||||
iterator find(const key_type& __k) {return __table_.find(__k);}
|
iterator find(const key_type& __k) {return __table_.find(__k);}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
|
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
template <typename _K2>
|
template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator>
|
iterator find(const _K2& __k) {return __table_.find(__k);}
|
||||||
find(const _K2& __k) {return __table_.find(__k);}
|
template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
template <typename _K2>
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
const_iterator find(const _K2& __k) const {return __table_.find(__k);}
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator>
|
#endif // _LIBCPP_STD_VER > 17
|
||||||
find(const _K2& __k) const {return __table_.find(__k);}
|
|
||||||
#endif // _LIBCPP_STD_VER > 17
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
|
size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
template <typename _K2>
|
template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type>
|
size_type count(const _K2& __k) const {return __table_.__count_multi(__k);}
|
||||||
count(const _K2& __k) const {return __table_.__count_multi(__k);}
|
#endif // _LIBCPP_STD_VER > 17
|
||||||
#endif // _LIBCPP_STD_VER > 17
|
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
bool contains(const key_type& __k) const {return find(__k) != end();}
|
bool contains(const key_type& __k) const {return find(__k) != end();}
|
||||||
|
|
||||||
|
template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
bool contains(const _K2& __k) const {return find(__k) != end();}
|
||||||
|
#endif // _LIBCPP_STD_VER > 17
|
||||||
|
|
||||||
template <typename _K2>
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool>
|
|
||||||
contains(const _K2& __k) const {return find(__k) != end();}
|
|
||||||
#endif // _LIBCPP_STD_VER > 17
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
pair<iterator, iterator> equal_range(const key_type& __k)
|
pair<iterator, iterator> equal_range(const key_type& __k)
|
||||||
{return __table_.__equal_range_multi(__k);}
|
{return __table_.__equal_range_multi(__k);}
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
|
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
|
||||||
{return __table_.__equal_range_multi(__k);}
|
{return __table_.__equal_range_multi(__k);}
|
||||||
#if _LIBCPP_STD_VER > 17
|
#if _LIBCPP_STD_VER > 17
|
||||||
template <typename _K2>
|
template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>>
|
pair<iterator, iterator> equal_range(const _K2& __k)
|
||||||
equal_range(const _K2& __k) {return __table_.__equal_range_multi(__k);}
|
{return __table_.__equal_range_multi(__k);}
|
||||||
template <typename _K2>
|
template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>>
|
pair<const_iterator, const_iterator> equal_range(const _K2& __k) const
|
||||||
equal_range(const _K2& __k) const {return __table_.__equal_range_multi(__k);}
|
{return __table_.__equal_range_multi(__k);}
|
||||||
#endif // _LIBCPP_STD_VER > 17
|
#endif // _LIBCPP_STD_VER > 17
|
||||||
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
|
size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
|
||||||
|
|
|
@ -23,39 +23,40 @@
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
using key_type = StoredType<int>;
|
using key_type = StoredType<int>;
|
||||||
using ilist_type = std::initializer_list<std::pair<const key_type, int> >;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
||||||
using map_type = const unord_map_type<std::unordered_map, transparent_hash, std::equal_to<> >;
|
using M = unord_map_type<std::unordered_map, transparent_hash, std::equal_to<>>;
|
||||||
test_transparent_contains<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_transparent_contains<M>({{1, 2}, {2, 3}});
|
||||||
|
test_transparent_contains<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
// Make sure conversions don't happen for transparent final hasher and key_equal
|
||||||
using map_type = const unord_map_type<std::unordered_map, transparent_hash_final, transparent_equal_final>;
|
using M = unord_map_type<std::unordered_map, transparent_hash_final, transparent_equal_final>;
|
||||||
test_transparent_contains<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_transparent_contains<M>({{1, 2}, {2, 3}});
|
||||||
|
test_transparent_contains<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
// Make sure conversions do happen for non-transparent hasher
|
||||||
using map_type = const unord_map_type<std::unordered_map, non_transparent_hash,
|
using M = unord_map_type<std::unordered_map, non_transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_non_transparent_contains<M>({{1, 2}, {2, 3}});
|
||||||
test_non_transparent_contains<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_non_transparent_contains<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
// Make sure conversions do happen for non-transparent key_equal
|
||||||
using map_type = const unord_map_type<std::unordered_map, transparent_hash,
|
using M = unord_map_type<std::unordered_map, transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_contains<M>({{1, 2}, {2, 3}});
|
||||||
test_non_transparent_contains<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_non_transparent_contains<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
||||||
using map_type = const unord_map_type<std::unordered_map, non_transparent_hash,
|
using M = unord_map_type<std::unordered_map, non_transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_contains<M>({{1, 2}, {2, 3}});
|
||||||
test_non_transparent_contains<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_non_transparent_contains<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -24,39 +24,40 @@
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
using key_type = StoredType<int>;
|
using key_type = StoredType<int>;
|
||||||
using ilist_type = std::initializer_list<std::pair<const key_type, int> >;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
||||||
using map_type = const unord_map_type<std::unordered_map, transparent_hash, std::equal_to<> >;
|
using M = unord_map_type<std::unordered_map, transparent_hash, std::equal_to<>>;
|
||||||
test_transparent_count<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_transparent_count<M>({{1, 2}, {2, 3}});
|
||||||
|
test_transparent_count<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
// Make sure conversions don't happen for transparent final hasher and key_equal
|
||||||
using map_type =
|
using M = unord_map_type<std::unordered_map, transparent_hash_final, transparent_equal_final>;
|
||||||
const unord_map_type<std::unordered_map, transparent_hash_final, transparent_equal_final>;
|
test_transparent_count<M>({{1, 2}, {2, 3}});
|
||||||
test_transparent_count<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_transparent_count<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
// Make sure conversions do happen for non-transparent hasher
|
||||||
using map_type = const unord_map_type<std::unordered_map, non_transparent_hash, std::equal_to<> >;
|
using M = unord_map_type<std::unordered_map, non_transparent_hash, std::equal_to<>>;
|
||||||
test_non_transparent_count<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_non_transparent_count<M>({{1, 2}, {2, 3}});
|
||||||
|
test_non_transparent_count<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
// Make sure conversions do happen for non-transparent key_equal
|
||||||
using map_type =
|
using M = unord_map_type<std::unordered_map, transparent_hash, std::equal_to<key_type>>;
|
||||||
const unord_map_type<std::unordered_map, transparent_hash, std::equal_to<key_type> >;
|
test_non_transparent_count<M>({{1, 2}, {2, 3}});
|
||||||
test_non_transparent_count<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_non_transparent_count<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
||||||
using map_type =
|
using M = unord_map_type<std::unordered_map, non_transparent_hash, std::equal_to<key_type>>;
|
||||||
const unord_map_type<std::unordered_map, non_transparent_hash, std::equal_to<key_type> >;
|
test_non_transparent_count<M>({{1, 2}, {2, 3}});
|
||||||
test_non_transparent_count<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_non_transparent_count<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -24,41 +24,40 @@
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
using key_type = StoredType<int>;
|
using key_type = StoredType<int>;
|
||||||
using ilist_type = std::initializer_list<std::pair<const key_type, int> >;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
||||||
using map_type = unord_map_type<std::unordered_map, transparent_hash,
|
using M = unord_map_type<std::unordered_map, transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_transparent_equal_range<M>({{1, 2}, {2, 3}});
|
||||||
test_transparent_equal_range<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_transparent_equal_range<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
// Make sure conversions don't happen for transparent final hasher and key_equal
|
||||||
using map_type = unord_map_type<std::unordered_map, transparent_hash_final,
|
using M = unord_map_type<std::unordered_map, transparent_hash_final, transparent_equal_final>;
|
||||||
transparent_equal_final>;
|
test_transparent_equal_range<M>({{1, 2}, {2, 3}});
|
||||||
test_transparent_equal_range<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_transparent_equal_range<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
// Make sure conversions do happen for non-transparent hasher
|
||||||
using map_type = unord_map_type<std::unordered_map, non_transparent_hash,
|
using M = unord_map_type<std::unordered_map, non_transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_non_transparent_equal_range<M>({{1, 2}, {2, 3}});
|
||||||
test_non_transparent_equal_range<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_non_transparent_equal_range<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
// Make sure conversions do happen for non-transparent key_equal
|
||||||
using map_type = unord_map_type<std::unordered_map, transparent_hash,
|
using M = unord_map_type<std::unordered_map, transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_equal_range<M>({{1, 2}, {2, 3}});
|
||||||
test_non_transparent_equal_range<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_non_transparent_equal_range<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
||||||
using map_type = unord_map_type<std::unordered_map, non_transparent_hash,
|
using M = unord_map_type<std::unordered_map, non_transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_equal_range<M>({{1, 2}, {2, 3}});
|
||||||
test_non_transparent_equal_range<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_non_transparent_equal_range<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
|
@ -1,65 +0,0 @@
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
|
||||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <unordered_map>
|
|
||||||
|
|
||||||
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
|
|
||||||
// class Alloc = allocator<pair<const Key, T>>>
|
|
||||||
// class unordered_map
|
|
||||||
|
|
||||||
// template <typename K>
|
|
||||||
// pair<const_iterator, const_iterator> equal_range(const K& k) const;
|
|
||||||
|
|
||||||
// UNSUPPORTED: c++03, c++11, c++14, c++17
|
|
||||||
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#include "test_transparent_unordered.h"
|
|
||||||
|
|
||||||
int main(int, char**)
|
|
||||||
{
|
|
||||||
using key_type = StoredType<int>;
|
|
||||||
using ilist_type = std::initializer_list<std::pair<const key_type, int> >;
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
|
||||||
using map_type = const unord_map_type<std::unordered_map, transparent_hash,
|
|
||||||
std::equal_to<> >;
|
|
||||||
test_transparent_equal_range<map_type>(ilist_type{{1, 2}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
|
||||||
using map_type = const unord_map_type<std::unordered_map, transparent_hash_final,
|
|
||||||
transparent_equal_final>;
|
|
||||||
test_transparent_equal_range<map_type>(ilist_type{{1, 2}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
|
||||||
using map_type = const unord_map_type<std::unordered_map, non_transparent_hash,
|
|
||||||
std::equal_to<> >;
|
|
||||||
test_non_transparent_equal_range<map_type>(ilist_type{{1, 2}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
|
||||||
using map_type = const unord_map_type<std::unordered_map, transparent_hash,
|
|
||||||
std::equal_to<key_type> >;
|
|
||||||
test_non_transparent_equal_range<map_type>(ilist_type{{1, 2}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
|
||||||
using map_type = const unord_map_type<std::unordered_map, non_transparent_hash,
|
|
||||||
std::equal_to<key_type> >;
|
|
||||||
test_non_transparent_equal_range<map_type>(ilist_type{{1, 2}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -24,41 +24,40 @@
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
using key_type = StoredType<int>;
|
using key_type = StoredType<int>;
|
||||||
using ilist_type = std::initializer_list<std::pair<const key_type, int> >;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
||||||
using map_type = unord_map_type<std::unordered_map, transparent_hash,
|
using M = unord_map_type<std::unordered_map, transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_transparent_find<M>({{1, 2}, {2, 3}});
|
||||||
test_transparent_find<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_transparent_find<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
// Make sure conversions don't happen for transparent final hasher and key_equal
|
||||||
using map_type = unord_map_type<std::unordered_map, transparent_hash_final,
|
using M = unord_map_type<std::unordered_map, transparent_hash_final, transparent_equal_final>;
|
||||||
transparent_equal_final>;
|
test_transparent_find<M>({{1, 2}, {2, 3}});
|
||||||
test_transparent_find<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_transparent_find<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
// Make sure conversions do happen for non-transparent hasher
|
||||||
using map_type = unord_map_type<std::unordered_map, non_transparent_hash,
|
using M = unord_map_type<std::unordered_map, non_transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_non_transparent_find<M>({{1, 2}, {2, 3}});
|
||||||
test_non_transparent_find<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_non_transparent_find<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
// Make sure conversions do happen for non-transparent key_equal
|
||||||
using map_type = unord_map_type<std::unordered_map, transparent_hash,
|
using M = unord_map_type<std::unordered_map, transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_find<M>({{1, 2}, {2, 3}});
|
||||||
test_non_transparent_find<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_non_transparent_find<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
||||||
using map_type = unord_map_type<std::unordered_map, non_transparent_hash,
|
using M = unord_map_type<std::unordered_map, non_transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_find<M>({{1, 2}, {2, 3}});
|
||||||
test_non_transparent_find<map_type>(ilist_type{{1, 2}, {2, 3}});
|
test_non_transparent_find<const M>({{1, 2}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
|
@ -1,65 +0,0 @@
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
|
||||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <unordered_map>
|
|
||||||
|
|
||||||
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
|
|
||||||
// class Alloc = allocator<pair<const Key, T>>>
|
|
||||||
// class unordered_map
|
|
||||||
|
|
||||||
// template <typename K>
|
|
||||||
// const_iterator find(const K& k) const;
|
|
||||||
|
|
||||||
// UNSUPPORTED: c++03, c++11, c++14, c++17
|
|
||||||
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#include "test_transparent_unordered.h"
|
|
||||||
|
|
||||||
int main(int, char**)
|
|
||||||
{
|
|
||||||
using key_type = StoredType<int>;
|
|
||||||
using ilist_type = std::initializer_list<std::pair<const key_type, int> >;
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
|
||||||
using map_type = const unord_map_type<std::unordered_map, transparent_hash,
|
|
||||||
std::equal_to<> >;
|
|
||||||
test_transparent_find<map_type>(ilist_type{{1, 2}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
|
||||||
using map_type = const unord_map_type<std::unordered_map, transparent_hash_final,
|
|
||||||
transparent_equal_final>;
|
|
||||||
test_transparent_find<map_type>(ilist_type{{1, 2}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
|
||||||
using map_type = const unord_map_type<std::unordered_map, non_transparent_hash,
|
|
||||||
std::equal_to<> >;
|
|
||||||
test_non_transparent_find<map_type>(ilist_type{{1, 2}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
|
||||||
using map_type = const unord_map_type<std::unordered_map, transparent_hash,
|
|
||||||
std::equal_to<key_type> >;
|
|
||||||
test_non_transparent_find<map_type>(ilist_type{{1, 2}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
|
||||||
using map_type = const unord_map_type<std::unordered_map, non_transparent_hash,
|
|
||||||
std::equal_to<key_type> >;
|
|
||||||
test_non_transparent_find<map_type>(ilist_type{{1, 2}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -23,42 +23,40 @@
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
using key_type = StoredType<int>;
|
using key_type = StoredType<int>;
|
||||||
using ilist_type = std::initializer_list<std::pair<const key_type, int> >;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
||||||
using map_type = unord_map_type<std::unordered_multimap, transparent_hash,
|
using M = unord_map_type<std::unordered_multimap, transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_transparent_contains<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
test_transparent_contains<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
test_transparent_contains<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
// Make sure conversions don't happen for transparent final hasher and key_equal
|
||||||
using map_type = unord_map_type<std::unordered_multimap, transparent_hash_final, transparent_equal_final>;
|
using M = unord_map_type<std::unordered_multimap, transparent_hash_final, transparent_equal_final>;
|
||||||
test_transparent_contains<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
test_transparent_contains<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
|
test_transparent_contains<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
// Make sure conversions do happen for non-transparent hasher
|
||||||
using map_type = unord_map_type<std::unordered_multimap, non_transparent_hash,
|
using M = unord_map_type<std::unordered_multimap, non_transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_non_transparent_contains<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
test_non_transparent_contains<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
test_non_transparent_contains<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
// Make sure conversions do happen for non-transparent key_equal
|
||||||
using map_type = unord_map_type<std::unordered_multimap, transparent_hash,
|
using M = unord_map_type<std::unordered_multimap, transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_contains<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
test_non_transparent_contains<map_type>(
|
test_non_transparent_contains<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
||||||
using map_type = unord_map_type<std::unordered_multimap, non_transparent_hash,
|
using M = unord_map_type<std::unordered_multimap, non_transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_contains<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
test_non_transparent_contains<map_type>(
|
test_non_transparent_contains<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -24,39 +24,40 @@
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
using key_type = StoredType<int>;
|
using key_type = StoredType<int>;
|
||||||
using ilist_type = std::initializer_list<std::pair<const key_type, int> >;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
||||||
using map_type = const unord_map_type<std::unordered_multimap, transparent_hash, std::equal_to<> >;
|
using M = unord_map_type<std::unordered_multimap, transparent_hash, std::equal_to<>>;
|
||||||
test_transparent_count<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
test_transparent_count<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
|
test_transparent_count<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
// Make sure conversions don't happen for transparent final hasher and key_equal
|
||||||
using map_type =
|
using M = unord_map_type<std::unordered_multimap, transparent_hash_final, transparent_equal_final>;
|
||||||
const unord_map_type<std::unordered_multimap, transparent_hash_final, transparent_equal_final>;
|
test_transparent_count<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
test_transparent_count<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
test_transparent_count<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
// Make sure conversions do happen for non-transparent hasher
|
||||||
using map_type = const unord_map_type<std::unordered_multimap, non_transparent_hash, std::equal_to<> >;
|
using M = unord_map_type<std::unordered_multimap, non_transparent_hash, std::equal_to<>>;
|
||||||
test_non_transparent_count<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
test_non_transparent_count<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
|
test_non_transparent_count<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
// Make sure conversions do happen for non-transparent key_equal
|
||||||
using map_type =
|
using M = unord_map_type<std::unordered_multimap, transparent_hash, std::equal_to<key_type>>;
|
||||||
const unord_map_type<std::unordered_multimap, transparent_hash, std::equal_to<key_type> >;
|
test_non_transparent_count<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
test_non_transparent_count<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
test_non_transparent_count<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
||||||
using map_type =
|
using M = unord_map_type<std::unordered_multimap, non_transparent_hash, std::equal_to<key_type>>;
|
||||||
const unord_map_type<std::unordered_multimap, non_transparent_hash, std::equal_to<key_type> >;
|
test_non_transparent_count<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
test_non_transparent_count<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
test_non_transparent_count<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -24,41 +24,40 @@
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
using key_type = StoredType<int>;
|
using key_type = StoredType<int>;
|
||||||
using ilist_type = std::initializer_list<std::pair<const key_type, int> >;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
||||||
using map_type = unord_map_type<std::unordered_multimap, transparent_hash,
|
using M = unord_map_type<std::unordered_multimap, transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_transparent_equal_range<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
test_transparent_equal_range<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
test_transparent_equal_range<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
// Make sure conversions don't happen for transparent final hasher and key_equal
|
||||||
using map_type = unord_map_type<std::unordered_multimap, transparent_hash_final,
|
using M = unord_map_type<std::unordered_multimap, transparent_hash_final, transparent_equal_final>;
|
||||||
transparent_equal_final>;
|
test_transparent_equal_range<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
test_transparent_equal_range<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
test_transparent_equal_range<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
// Make sure conversions do happen for non-transparent hasher
|
||||||
using map_type = unord_map_type<std::unordered_multimap, non_transparent_hash,
|
using M = unord_map_type<std::unordered_multimap, non_transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_non_transparent_equal_range<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
test_non_transparent_equal_range<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
test_non_transparent_equal_range<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
// Make sure conversions do happen for non-transparent key_equal
|
||||||
using map_type = unord_map_type<std::unordered_multimap, transparent_hash,
|
using M = unord_map_type<std::unordered_multimap, transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_equal_range<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
test_non_transparent_equal_range<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
test_non_transparent_equal_range<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
||||||
using map_type = unord_map_type<std::unordered_multimap, non_transparent_hash,
|
using M = unord_map_type<std::unordered_multimap, non_transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_equal_range<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
test_non_transparent_equal_range<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
test_non_transparent_equal_range<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
|
@ -1,65 +0,0 @@
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
|
||||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <unordered_map>
|
|
||||||
|
|
||||||
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
|
|
||||||
// class Alloc = allocator<pair<const Key, T>>>
|
|
||||||
// class unordered_multimap
|
|
||||||
|
|
||||||
// template <typename K>
|
|
||||||
// pair<const_iterator, const_iterator> equal_range(const K& k) const;
|
|
||||||
|
|
||||||
// UNSUPPORTED: c++03, c++11, c++14, c++17
|
|
||||||
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#include "test_transparent_unordered.h"
|
|
||||||
|
|
||||||
int main(int, char**)
|
|
||||||
{
|
|
||||||
using key_type = StoredType<int>;
|
|
||||||
using ilist_type = std::initializer_list<std::pair<const key_type, int> >;
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
|
||||||
using map_type = const unord_map_type<std::unordered_multimap, transparent_hash,
|
|
||||||
std::equal_to<> >;
|
|
||||||
test_transparent_equal_range<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
|
||||||
using map_type = const unord_map_type<std::unordered_multimap, transparent_hash_final,
|
|
||||||
transparent_equal_final>;
|
|
||||||
test_transparent_equal_range<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
|
||||||
using map_type = const unord_map_type<std::unordered_multimap, non_transparent_hash,
|
|
||||||
std::equal_to<> >;
|
|
||||||
test_non_transparent_equal_range<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
|
||||||
using map_type = const unord_map_type<std::unordered_multimap, transparent_hash,
|
|
||||||
std::equal_to<key_type> >;
|
|
||||||
test_non_transparent_equal_range<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
|
||||||
using map_type = const unord_map_type<std::unordered_multimap, non_transparent_hash,
|
|
||||||
std::equal_to<key_type> >;
|
|
||||||
test_non_transparent_equal_range<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -24,41 +24,40 @@
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
using key_type = StoredType<int>;
|
using key_type = StoredType<int>;
|
||||||
using ilist_type = std::initializer_list<std::pair<const key_type, int> >;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
||||||
using map_type = unord_map_type<std::unordered_multimap, transparent_hash,
|
using M = unord_map_type<std::unordered_multimap, transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_transparent_find<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
test_transparent_find<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
test_transparent_find<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
// Make sure conversions don't happen for transparent final hasher and key_equal
|
||||||
using map_type = unord_map_type<std::unordered_multimap, transparent_hash_final,
|
using M = unord_map_type<std::unordered_multimap, transparent_hash_final, transparent_equal_final>;
|
||||||
transparent_equal_final>;
|
test_transparent_find<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
test_transparent_find<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
test_transparent_find<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
// Make sure conversions do happen for non-transparent hasher
|
||||||
using map_type = unord_map_type<std::unordered_multimap, non_transparent_hash,
|
using M = unord_map_type<std::unordered_multimap, non_transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_non_transparent_find<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
test_non_transparent_find<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
test_non_transparent_find<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
// Make sure conversions do happen for non-transparent key_equal
|
||||||
using map_type = unord_map_type<std::unordered_multimap, transparent_hash,
|
using M = unord_map_type<std::unordered_multimap, transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_find<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
test_non_transparent_find<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
test_non_transparent_find<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
||||||
using map_type = unord_map_type<std::unordered_multimap, non_transparent_hash,
|
using M = unord_map_type<std::unordered_multimap, non_transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_find<M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
test_non_transparent_find<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
test_non_transparent_find<const M>({{1, 2}, {1, 3}, {2, 3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
|
@ -1,65 +0,0 @@
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
|
||||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <unordered_map>
|
|
||||||
|
|
||||||
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
|
|
||||||
// class Alloc = allocator<pair<const Key, T>>>
|
|
||||||
// class unordered_multimap
|
|
||||||
|
|
||||||
// template <typename K>
|
|
||||||
// const_iterator find(const K& k) const;
|
|
||||||
|
|
||||||
// UNSUPPORTED: c++03, c++11, c++14, c++17
|
|
||||||
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#include "test_transparent_unordered.h"
|
|
||||||
|
|
||||||
int main(int, char**)
|
|
||||||
{
|
|
||||||
using key_type = StoredType<int>;
|
|
||||||
using ilist_type = std::initializer_list<std::pair<const key_type, int> >;
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
|
||||||
using map_type = const unord_map_type<std::unordered_multimap, transparent_hash,
|
|
||||||
std::equal_to<> >;
|
|
||||||
test_transparent_find<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
|
||||||
using map_type = const unord_map_type<std::unordered_multimap, transparent_hash_final,
|
|
||||||
transparent_equal_final>;
|
|
||||||
test_transparent_find<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
|
||||||
using map_type = const unord_map_type<std::unordered_multimap, non_transparent_hash,
|
|
||||||
std::equal_to<> >;
|
|
||||||
test_non_transparent_find<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
|
||||||
using map_type = const unord_map_type<std::unordered_multimap, transparent_hash,
|
|
||||||
std::equal_to<key_type> >;
|
|
||||||
test_non_transparent_find<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
|
||||||
using map_type = const unord_map_type<std::unordered_multimap, non_transparent_hash,
|
|
||||||
std::equal_to<key_type> >;
|
|
||||||
test_non_transparent_find<map_type>(ilist_type{{1, 2}, {1, 3}, {2, 3}});
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -26,38 +26,37 @@ int main(int, char**)
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
||||||
using set_type = unord_set_type<std::unordered_multiset, transparent_hash,
|
using S = unord_set_type<std::unordered_multiset, transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_transparent_contains<S>({1, 1, 2});
|
||||||
test_transparent_contains<set_type>(key_type{1}, key_type{1}, key_type{2});
|
test_transparent_contains<const S>({1, 1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
// Make sure conversions don't happen for transparent final hasher and key_equal
|
||||||
using set_type = unord_set_type<std::unordered_multiset, transparent_hash_final, transparent_equal_final>;
|
using S = unord_set_type<std::unordered_multiset, transparent_hash_final, transparent_equal_final>;
|
||||||
test_transparent_contains<set_type>(key_type{1}, key_type{1}, key_type{2});
|
test_transparent_contains<S>({1, 1, 2});
|
||||||
|
test_transparent_contains<const S>({1, 1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
// Make sure conversions do happen for non-transparent hasher
|
||||||
using set_type = unord_set_type<std::unordered_multiset, non_transparent_hash,
|
using S = unord_set_type<std::unordered_multiset, non_transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_non_transparent_contains<S>({1, 1, 2});
|
||||||
test_non_transparent_contains<set_type>(key_type{1}, key_type{1}, key_type{2});
|
test_non_transparent_contains<const S>({1, 1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
// Make sure conversions do happen for non-transparent key_equal
|
||||||
using set_type = unord_set_type<std::unordered_multiset, transparent_hash,
|
using S = unord_set_type<std::unordered_multiset, transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_contains<S>({1, 1, 2});
|
||||||
test_non_transparent_contains<set_type>(
|
test_non_transparent_contains<const S>({1, 1, 2});
|
||||||
key_type{1}, key_type{1}, key_type{2});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
||||||
using set_type = unord_set_type<std::unordered_multiset, non_transparent_hash,
|
using S = unord_set_type<std::unordered_multiset, non_transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_contains<S>({1, 1, 2});
|
||||||
test_non_transparent_contains<set_type>(
|
test_non_transparent_contains<const S>({1, 1, 2});
|
||||||
key_type{1}, key_type{1}, key_type{2});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -27,35 +27,37 @@ int main(int, char**)
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
||||||
using set_type = const unord_set_type<std::unordered_multiset, transparent_hash, std::equal_to<> >;
|
using S = unord_set_type<std::unordered_multiset, transparent_hash, std::equal_to<>>;
|
||||||
test_transparent_count<set_type>(key_type{1}, key_type{1}, key_type{2});
|
test_transparent_count<S>({1, 1, 2});
|
||||||
|
test_transparent_count<const S>({1, 1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
// Make sure conversions don't happen for transparent final hasher and key_equal
|
||||||
using set_type =
|
using S = unord_set_type<std::unordered_multiset, transparent_hash_final, transparent_equal_final>;
|
||||||
const unord_set_type<std::unordered_multiset, transparent_hash_final, transparent_equal_final>;
|
test_transparent_count<S>({1, 1, 2});
|
||||||
test_transparent_count<set_type>(key_type{1}, key_type{1}, key_type{2});
|
test_transparent_count<const S>({1, 1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
// Make sure conversions do happen for non-transparent hasher
|
||||||
using set_type = const unord_set_type<std::unordered_multiset, non_transparent_hash, std::equal_to<> >;
|
using S = unord_set_type<std::unordered_multiset, non_transparent_hash, std::equal_to<>>;
|
||||||
test_non_transparent_count<set_type>(key_type{1}, key_type{1}, key_type{2});
|
test_non_transparent_count<S>({1, 1, 2});
|
||||||
|
test_non_transparent_count<const S>({1, 1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
// Make sure conversions do happen for non-transparent key_equal
|
||||||
using set_type =
|
using S = unord_set_type<std::unordered_multiset, transparent_hash, std::equal_to<key_type>>;
|
||||||
const unord_set_type<std::unordered_multiset, transparent_hash, std::equal_to<key_type> >;
|
test_non_transparent_count<S>({1, 1, 2});
|
||||||
test_non_transparent_count<set_type>(key_type{1}, key_type{1}, key_type{2});
|
test_non_transparent_count<const S>({1, 1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
||||||
using set_type =
|
using S = unord_set_type<std::unordered_multiset, non_transparent_hash, std::equal_to<key_type>>;
|
||||||
const unord_set_type<std::unordered_multiset, non_transparent_hash, std::equal_to<key_type> >;
|
test_non_transparent_count<S>({1, 1, 2});
|
||||||
test_non_transparent_count<set_type>(key_type{1}, key_type{1}, key_type{2});
|
test_non_transparent_count<const S>({1, 1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
|
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
|
||||||
// class Alloc = allocator<pair<const Key, T>>>
|
// class Alloc = allocator<pair<const Key, T>>>
|
||||||
// class unordered_set
|
// class unordered_multiset
|
||||||
|
|
||||||
// template <typename K>
|
// template <typename K>
|
||||||
// pair<const_iterator, const_iterator> equal_range(const K& k) const;
|
// pair<const_iterator, const_iterator> equal_range(const K& k) const;
|
||||||
|
@ -27,37 +27,37 @@ int main(int, char**)
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
||||||
using set_type = const unord_set_type<std::unordered_set, transparent_hash,
|
using S = unord_set_type<std::unordered_multiset, transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_transparent_equal_range<S>({1, 1, 2});
|
||||||
test_transparent_equal_range<set_type>(key_type{1}, key_type{2});
|
test_transparent_equal_range<const S>({1, 1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
// Make sure conversions don't happen for transparent final hasher and key_equal
|
||||||
using set_type = const unord_set_type<std::unordered_set, transparent_hash_final,
|
using S = unord_set_type<std::unordered_multiset, transparent_hash_final, transparent_equal_final>;
|
||||||
transparent_equal_final>;
|
test_transparent_equal_range<S>({1, 1, 2});
|
||||||
test_transparent_equal_range<set_type>(key_type{1}, key_type{2});
|
test_transparent_equal_range<const S>({1, 1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
// Make sure conversions do happen for non-transparent hasher
|
||||||
using set_type = const unord_set_type<std::unordered_set, non_transparent_hash,
|
using S = unord_set_type<std::unordered_multiset, non_transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_non_transparent_equal_range<S>({1, 1, 2});
|
||||||
test_non_transparent_equal_range<set_type>(key_type{1}, key_type{2});
|
test_non_transparent_equal_range<const S>({1, 1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
// Make sure conversions do happen for non-transparent key_equal
|
||||||
using set_type = const unord_set_type<std::unordered_set, transparent_hash,
|
using S = unord_set_type<std::unordered_multiset, transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_equal_range<S>({1, 1, 2});
|
||||||
test_non_transparent_equal_range<set_type>(key_type{1}, key_type{2});
|
test_non_transparent_equal_range<const S>({1, 1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
||||||
using set_type = const unord_set_type<std::unordered_set, non_transparent_hash,
|
using S = unord_set_type<std::unordered_multiset, non_transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_equal_range<S>({1, 1, 2});
|
||||||
test_non_transparent_equal_range<set_type>(key_type{1}, key_type{2});
|
test_non_transparent_equal_range<const S>({1, 1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
|
@ -1,64 +0,0 @@
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
|
||||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <unordered_set>
|
|
||||||
|
|
||||||
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
|
|
||||||
// class Alloc = allocator<pair<const Key, T>>>
|
|
||||||
// class unordered_multiset
|
|
||||||
|
|
||||||
// template <typename K>
|
|
||||||
// pair<const_iterator, const_iterator> equal_range(const K& k) const;
|
|
||||||
|
|
||||||
// UNSUPPORTED: c++03, c++11, c++14, c++17
|
|
||||||
|
|
||||||
#include <unordered_set>
|
|
||||||
|
|
||||||
#include "test_transparent_unordered.h"
|
|
||||||
|
|
||||||
int main(int, char**)
|
|
||||||
{
|
|
||||||
using key_type = StoredType<int>;
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
|
||||||
using set_type = const unord_set_type<std::unordered_multiset, transparent_hash,
|
|
||||||
std::equal_to<> >;
|
|
||||||
test_transparent_equal_range<set_type>(key_type{1}, key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
|
||||||
using set_type = const unord_set_type<std::unordered_multiset, transparent_hash_final,
|
|
||||||
transparent_equal_final>;
|
|
||||||
test_transparent_equal_range<set_type>(key_type{1}, key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
|
||||||
using set_type = const unord_set_type<std::unordered_multiset, non_transparent_hash,
|
|
||||||
std::equal_to<> >;
|
|
||||||
test_non_transparent_equal_range<set_type>(key_type{1}, key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
|
||||||
using set_type = const unord_set_type<std::unordered_multiset, transparent_hash,
|
|
||||||
std::equal_to<key_type> >;
|
|
||||||
test_non_transparent_equal_range<set_type>(key_type{1}, key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
|
||||||
using set_type = const unord_set_type<std::unordered_multiset, non_transparent_hash,
|
|
||||||
std::equal_to<key_type> >;
|
|
||||||
test_non_transparent_equal_range<set_type>(key_type{1}, key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,64 +0,0 @@
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
|
||||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <unordered_set>
|
|
||||||
|
|
||||||
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
|
|
||||||
// class Alloc = allocator<pair<const Key, T>>>
|
|
||||||
// class unordered_multiset
|
|
||||||
|
|
||||||
// template <typename K>
|
|
||||||
// pair<iterator, iterator> equal_range(const K& k);
|
|
||||||
|
|
||||||
// UNSUPPORTED: c++03, c++11, c++14, c++17
|
|
||||||
|
|
||||||
#include <unordered_set>
|
|
||||||
|
|
||||||
#include "test_transparent_unordered.h"
|
|
||||||
|
|
||||||
int main(int, char**)
|
|
||||||
{
|
|
||||||
using key_type = StoredType<int>;
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
|
||||||
using set_type = unord_set_type<std::unordered_multiset, transparent_hash,
|
|
||||||
std::equal_to<> >;
|
|
||||||
test_transparent_equal_range<set_type>(key_type{1}, key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
|
||||||
using set_type = unord_set_type<std::unordered_multiset, transparent_hash_final,
|
|
||||||
transparent_equal_final>;
|
|
||||||
test_transparent_equal_range<set_type>(key_type{1}, key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
|
||||||
using set_type = unord_set_type<std::unordered_multiset, non_transparent_hash,
|
|
||||||
std::equal_to<> >;
|
|
||||||
test_non_transparent_equal_range<set_type>(key_type{1}, key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
|
||||||
using set_type = unord_set_type<std::unordered_multiset, transparent_hash,
|
|
||||||
std::equal_to<key_type> >;
|
|
||||||
test_non_transparent_equal_range<set_type>(key_type{1}, key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
|
||||||
using set_type = unord_set_type<std::unordered_multiset, non_transparent_hash,
|
|
||||||
std::equal_to<key_type> >;
|
|
||||||
test_non_transparent_equal_range<set_type>(key_type{1}, key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -27,37 +27,37 @@ int main(int, char**)
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
||||||
using set_type = unord_set_type<std::unordered_multiset, transparent_hash,
|
using S = unord_set_type<std::unordered_multiset, transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_transparent_find<S>({1, 1, 2});
|
||||||
test_transparent_find<set_type>(key_type{1}, key_type{1}, key_type{2});
|
test_transparent_find<const S>({1, 1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
// Make sure conversions don't happen for transparent final hasher and key_equal
|
||||||
using set_type = unord_set_type<std::unordered_multiset, transparent_hash_final,
|
using S = unord_set_type<std::unordered_multiset, transparent_hash_final, transparent_equal_final>;
|
||||||
transparent_equal_final>;
|
test_transparent_find<S>({1, 1, 2});
|
||||||
test_transparent_find<set_type>(key_type{1}, key_type{1}, key_type{2});
|
test_transparent_find<const S>({1, 1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
// Make sure conversions do happen for non-transparent hasher
|
||||||
using set_type = unord_set_type<std::unordered_multiset, non_transparent_hash,
|
using S = unord_set_type<std::unordered_multiset, non_transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_non_transparent_find<S>({1, 1, 2});
|
||||||
test_non_transparent_find<set_type>(key_type{1}, key_type{1}, key_type{2});
|
test_non_transparent_find<const S>({1, 1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
// Make sure conversions do happen for non-transparent key_equal
|
||||||
using set_type = unord_set_type<std::unordered_multiset, transparent_hash,
|
using S = unord_set_type<std::unordered_multiset, transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_find<S>({1, 1, 2});
|
||||||
test_non_transparent_find<set_type>(key_type{1}, key_type{1}, key_type{2});
|
test_non_transparent_find<const S>({1, 1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
||||||
using set_type = unord_set_type<std::unordered_multiset, non_transparent_hash,
|
using S = unord_set_type<std::unordered_multiset, non_transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_find<S>({1, 1, 2});
|
||||||
test_non_transparent_find<set_type>(key_type{1}, key_type{1}, key_type{2});
|
test_non_transparent_find<const S>({1, 1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
|
@ -1,64 +0,0 @@
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
|
||||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <unordered_set>
|
|
||||||
|
|
||||||
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
|
|
||||||
// class Alloc = allocator<pair<const Key, T>>>
|
|
||||||
// class unordered_multiset
|
|
||||||
|
|
||||||
// template <typename K>
|
|
||||||
// const_iterator find(const K& k) const;
|
|
||||||
|
|
||||||
// UNSUPPORTED: c++03, c++11, c++14, c++17
|
|
||||||
|
|
||||||
#include <unordered_set>
|
|
||||||
|
|
||||||
#include "test_transparent_unordered.h"
|
|
||||||
|
|
||||||
int main(int, char**)
|
|
||||||
{
|
|
||||||
using key_type = StoredType<int>;
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
|
||||||
using set_type = const unord_set_type<std::unordered_multiset, transparent_hash,
|
|
||||||
std::equal_to<> >;
|
|
||||||
test_transparent_find<set_type>(key_type{1}, key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
|
||||||
using set_type = const unord_set_type<std::unordered_multiset, transparent_hash_final,
|
|
||||||
transparent_equal_final>;
|
|
||||||
test_transparent_find<set_type>(key_type{1}, key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
|
||||||
using set_type = const unord_set_type<std::unordered_multiset, non_transparent_hash,
|
|
||||||
std::equal_to<> >;
|
|
||||||
test_non_transparent_find<set_type>(key_type{1}, key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
|
||||||
using set_type = const unord_set_type<std::unordered_multiset, transparent_hash,
|
|
||||||
std::equal_to<key_type> >;
|
|
||||||
test_non_transparent_find<set_type>(key_type{1}, key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
|
||||||
using set_type = const unord_set_type<std::unordered_multiset, non_transparent_hash,
|
|
||||||
std::equal_to<key_type> >;
|
|
||||||
test_non_transparent_find<set_type>(key_type{1}, key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
|
// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
|
||||||
// class Alloc = allocator<Value>>
|
// class Alloc = allocator<Value>>
|
||||||
// class unordered_multiset
|
// class unordered_set
|
||||||
|
|
||||||
// template <typename K>
|
// template <typename K>
|
||||||
// bool contains(const K& x) const;
|
// bool contains(const K& x) const;
|
||||||
|
@ -26,35 +26,37 @@ int main(int, char**)
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
||||||
using set_type = const unord_set_type<std::unordered_set, transparent_hash, std::equal_to<> >;
|
using S = unord_set_type<std::unordered_set, transparent_hash, std::equal_to<>>;
|
||||||
test_transparent_contains<set_type>(key_type(1), key_type(2));
|
test_transparent_contains<S>({1, 2});
|
||||||
|
test_transparent_contains<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
// Make sure conversions don't happen for transparent final hasher and key_equal
|
||||||
using set_type = const unord_set_type<std::unordered_set, transparent_hash_final, transparent_equal_final>;
|
using S = unord_set_type<std::unordered_set, transparent_hash_final, transparent_equal_final>;
|
||||||
test_transparent_contains<set_type>(key_type(1), key_type(2));
|
test_transparent_contains<S>({1, 2});
|
||||||
|
test_transparent_contains<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
// Make sure conversions do happen for non-transparent hasher
|
||||||
using set_type = const unord_set_type<std::unordered_set, non_transparent_hash,
|
using S = unord_set_type<std::unordered_set, non_transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_non_transparent_contains<S>({1, 2});
|
||||||
test_non_transparent_contains<set_type>(key_type(1), key_type(2));
|
test_non_transparent_contains<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
// Make sure conversions do happen for non-transparent key_equal
|
||||||
using set_type = const unord_set_type<std::unordered_set, transparent_hash,
|
using S = unord_set_type<std::unordered_set, transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_contains<S>({1, 2});
|
||||||
test_non_transparent_contains<set_type>(key_type(1), key_type(2));
|
test_non_transparent_contains<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
||||||
using set_type = const unord_set_type<std::unordered_set, non_transparent_hash,
|
using S = unord_set_type<std::unordered_set, non_transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_contains<S>({1, 2});
|
||||||
test_non_transparent_contains<set_type>(key_type(1), key_type(2));
|
test_non_transparent_contains<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -27,35 +27,37 @@ int main(int, char**)
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
||||||
using set_type = const unord_set_type<std::unordered_set, transparent_hash, std::equal_to<> >;
|
using S = unord_set_type<std::unordered_set, transparent_hash, std::equal_to<>>;
|
||||||
test_transparent_count<set_type>(key_type{1}, key_type{2});
|
test_transparent_count<S>({1, 2});
|
||||||
|
test_transparent_count<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
// Make sure conversions don't happen for transparent final hasher and key_equal
|
||||||
using set_type =
|
using S = unord_set_type<std::unordered_set, transparent_hash_final, transparent_equal_final>;
|
||||||
const unord_set_type<std::unordered_set, transparent_hash_final, transparent_equal_final>;
|
test_transparent_count<S>({1, 2});
|
||||||
test_transparent_count<set_type>(key_type{1}, key_type{2});
|
test_transparent_count<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
// Make sure conversions do happen for non-transparent hasher
|
||||||
using set_type = const unord_set_type<std::unordered_set, non_transparent_hash, std::equal_to<> >;
|
using S = unord_set_type<std::unordered_set, non_transparent_hash, std::equal_to<>>;
|
||||||
test_non_transparent_count<set_type>(key_type{1}, key_type{2});
|
test_non_transparent_count<S>({1, 2});
|
||||||
|
test_non_transparent_count<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
// Make sure conversions do happen for non-transparent key_equal
|
||||||
using set_type =
|
using S = unord_set_type<std::unordered_set, transparent_hash, std::equal_to<key_type>>;
|
||||||
const unord_set_type<std::unordered_set, transparent_hash, std::equal_to<key_type> >;
|
test_non_transparent_count<S>({1, 2});
|
||||||
test_non_transparent_count<set_type>(key_type{1}, key_type{2});
|
test_non_transparent_count<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
||||||
using set_type =
|
using S = unord_set_type<std::unordered_set, non_transparent_hash, std::equal_to<key_type>>;
|
||||||
const unord_set_type<std::unordered_set, non_transparent_hash, std::equal_to<key_type> >;
|
test_non_transparent_count<S>({1, 2});
|
||||||
test_non_transparent_count<set_type>(key_type{1}, key_type{2});
|
test_non_transparent_count<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -27,37 +27,37 @@ int main(int, char**)
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
||||||
using set_type = unord_set_type<std::unordered_set, transparent_hash,
|
using S = unord_set_type<std::unordered_set, transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_transparent_equal_range<S>({1, 2});
|
||||||
test_transparent_equal_range<set_type>(key_type{1}, key_type{2});
|
test_transparent_equal_range<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
// Make sure conversions don't happen for transparent final hasher and key_equal
|
||||||
using set_type = unord_set_type<std::unordered_set, transparent_hash_final,
|
using S = unord_set_type<std::unordered_set, transparent_hash_final, transparent_equal_final>;
|
||||||
transparent_equal_final>;
|
test_transparent_equal_range<S>({1, 2});
|
||||||
test_transparent_equal_range<set_type>(key_type{1}, key_type{2});
|
test_transparent_equal_range<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
// Make sure conversions do happen for non-transparent hasher
|
||||||
using set_type = unord_set_type<std::unordered_set, non_transparent_hash,
|
using S = unord_set_type<std::unordered_set, non_transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_non_transparent_equal_range<S>({1, 2});
|
||||||
test_non_transparent_equal_range<set_type>(key_type{1}, key_type{2});
|
test_non_transparent_equal_range<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
// Make sure conversions do happen for non-transparent key_equal
|
||||||
using set_type = unord_set_type<std::unordered_set, transparent_hash,
|
using S = unord_set_type<std::unordered_set, transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_equal_range<S>({1, 2});
|
||||||
test_non_transparent_equal_range<set_type>(key_type{1}, key_type{2});
|
test_non_transparent_equal_range<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
||||||
using set_type = unord_set_type<std::unordered_set, non_transparent_hash,
|
using S = unord_set_type<std::unordered_set, non_transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_equal_range<S>({1, 2});
|
||||||
test_non_transparent_equal_range<set_type>(key_type{1}, key_type{2});
|
test_non_transparent_equal_range<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
|
@ -27,37 +27,37 @@ int main(int, char**)
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
||||||
using set_type = unord_set_type<std::unordered_set, transparent_hash,
|
using S = unord_set_type<std::unordered_set, transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_transparent_find<S>({1, 2});
|
||||||
test_transparent_find<set_type>(key_type{1}, key_type{2});
|
test_transparent_find<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
// Make sure conversions don't happen for transparent final hasher and key_equal
|
||||||
using set_type = unord_set_type<std::unordered_set, transparent_hash_final,
|
using S = unord_set_type<std::unordered_set, transparent_hash_final, transparent_equal_final>;
|
||||||
transparent_equal_final>;
|
test_transparent_find<S>({1, 2});
|
||||||
test_transparent_find<set_type>(key_type{1}, key_type{2});
|
test_transparent_find<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
// Make sure conversions do happen for non-transparent hasher
|
||||||
using set_type = unord_set_type<std::unordered_set, non_transparent_hash,
|
using S = unord_set_type<std::unordered_set, non_transparent_hash, std::equal_to<>>;
|
||||||
std::equal_to<> >;
|
test_non_transparent_find<S>({1, 2});
|
||||||
test_non_transparent_find<set_type>(key_type{1}, key_type{2});
|
test_non_transparent_find<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
// Make sure conversions do happen for non-transparent key_equal
|
||||||
using set_type = unord_set_type<std::unordered_set, transparent_hash,
|
using S = unord_set_type<std::unordered_set, transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_find<S>({1, 2});
|
||||||
test_non_transparent_find<set_type>(key_type{1}, key_type{2});
|
test_non_transparent_find<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
||||||
using set_type = unord_set_type<std::unordered_set, non_transparent_hash,
|
using S = unord_set_type<std::unordered_set, non_transparent_hash, std::equal_to<key_type>>;
|
||||||
std::equal_to<key_type> >;
|
test_non_transparent_find<S>({1, 2});
|
||||||
test_non_transparent_find<set_type>(key_type{1}, key_type{2});
|
test_non_transparent_find<const S>({1, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
|
@ -1,64 +0,0 @@
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
|
||||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <unordered_set>
|
|
||||||
|
|
||||||
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
|
|
||||||
// class Alloc = allocator<pair<const Key, T>>>
|
|
||||||
// class unordered_set
|
|
||||||
|
|
||||||
// template <typename K>
|
|
||||||
// const_iterator find(const K& k) const;
|
|
||||||
|
|
||||||
// UNSUPPORTED: c++03, c++11, c++14, c++17
|
|
||||||
|
|
||||||
#include <unordered_set>
|
|
||||||
|
|
||||||
#include "test_transparent_unordered.h"
|
|
||||||
|
|
||||||
int main(int, char**)
|
|
||||||
{
|
|
||||||
using key_type = StoredType<int>;
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions don't happen for transparent non-final hasher and key_equal
|
|
||||||
using set_type = const unord_set_type<std::unordered_set, transparent_hash,
|
|
||||||
std::equal_to<> >;
|
|
||||||
test_transparent_find<set_type>(key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions don't happen for transparent final hasher and key_equal
|
|
||||||
using set_type = const unord_set_type<std::unordered_set, transparent_hash_final,
|
|
||||||
transparent_equal_final>;
|
|
||||||
test_transparent_find<set_type>(key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for non-transparent hasher
|
|
||||||
using set_type = const unord_set_type<std::unordered_set, non_transparent_hash,
|
|
||||||
std::equal_to<> >;
|
|
||||||
test_non_transparent_find<set_type>(key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for non-transparent key_equal
|
|
||||||
using set_type = const unord_set_type<std::unordered_set, transparent_hash,
|
|
||||||
std::equal_to<key_type> >;
|
|
||||||
test_non_transparent_find<set_type>(key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// Make sure conversions do happen for both non-transparent hasher and key_equal
|
|
||||||
using set_type = const unord_set_type<std::unordered_set, non_transparent_hash,
|
|
||||||
std::equal_to<key_type> >;
|
|
||||||
test_non_transparent_find<set_type>(key_type{1}, key_type{2});
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -83,85 +83,4 @@ bool operator <(const C2Int& rhs, int lhs) { return rhs.get() < lhs;
|
||||||
|
|
||||||
#endif // TEST_STD_VER > 11
|
#endif // TEST_STD_VER > 11
|
||||||
|
|
||||||
#if TEST_STD_VER > 17
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct StoredType;
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct SearchedType;
|
|
||||||
|
|
||||||
struct hash_impl {
|
|
||||||
template <typename T>
|
|
||||||
constexpr std::size_t operator()(SearchedType<T> const& t) const {
|
|
||||||
return static_cast<std::size_t>(t.get_value());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
constexpr std::size_t operator()(StoredType<T> const& t) const {
|
|
||||||
return static_cast<std::size_t>(t.get_value());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct non_transparent_hash : hash_impl {};
|
|
||||||
|
|
||||||
struct transparent_hash : hash_impl {
|
|
||||||
using is_transparent = void;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct transparent_hash_final final : transparent_hash {};
|
|
||||||
|
|
||||||
struct transparent_equal_final final : std::equal_to<> {};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct SearchedType {
|
|
||||||
SearchedType(T value, int* counter) : value_(value), conversions_(counter) { }
|
|
||||||
|
|
||||||
// Whenever a conversion is performed, increment the counter to keep track
|
|
||||||
// of conversions.
|
|
||||||
operator StoredType<T>() const {
|
|
||||||
++*conversions_;
|
|
||||||
return StoredType<T>{value_};
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_value() const {
|
|
||||||
return value_;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
T value_;
|
|
||||||
int* conversions_;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct StoredType {
|
|
||||||
StoredType() = default;
|
|
||||||
StoredType(T value) : value_(value) { }
|
|
||||||
|
|
||||||
friend bool operator==(StoredType const& lhs, StoredType const& rhs) {
|
|
||||||
return lhs.value_ == rhs.value_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we're being passed a SearchedType<T> object, avoid the conversion
|
|
||||||
// to T. This allows testing that the transparent operations are correctly
|
|
||||||
// forwarding the SearchedType all the way to this comparison by checking
|
|
||||||
// that we didn't have a conversion when we search for a SearchedType<T>
|
|
||||||
// in a container full of StoredType<T>.
|
|
||||||
friend bool operator==(StoredType const& lhs, SearchedType<T> const& rhs) {
|
|
||||||
return lhs.value_ == rhs.get_value();
|
|
||||||
}
|
|
||||||
friend bool operator==(SearchedType<T> const& lhs, StoredType<T> const& rhs) {
|
|
||||||
return lhs.get_value() == rhs.value_;
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_value() const {
|
|
||||||
return value_;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
T value_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // TEST_STD_VER > 17
|
|
||||||
|
|
||||||
#endif // TRANSPARENT_H
|
#endif // TRANSPARENT_H
|
||||||
|
|
|
@ -14,121 +14,172 @@
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
// testing transparent unordered containers
|
|
||||||
#if TEST_STD_VER > 17
|
#if TEST_STD_VER > 17
|
||||||
|
|
||||||
template <template <typename...> class UnorderedSet, typename Hash,
|
template <typename T>
|
||||||
typename Equal>
|
struct StoredType;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct SearchedType;
|
||||||
|
|
||||||
|
struct hash_impl {
|
||||||
|
template <typename T>
|
||||||
|
constexpr std::size_t operator()(SearchedType<T> const& t) const {
|
||||||
|
return static_cast<std::size_t>(t.get_value());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr std::size_t operator()(StoredType<T> const& t) const {
|
||||||
|
return static_cast<std::size_t>(t.get_value());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct non_transparent_hash : hash_impl {};
|
||||||
|
|
||||||
|
struct transparent_hash : hash_impl {
|
||||||
|
using is_transparent = void;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct transparent_hash_final final : transparent_hash {};
|
||||||
|
|
||||||
|
struct transparent_equal_final final : std::equal_to<> {};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct SearchedType {
|
||||||
|
explicit SearchedType(T value, int *counter) : value_(value), conversions_(counter) { }
|
||||||
|
|
||||||
|
// Whenever a conversion is performed, increment the counter to keep track
|
||||||
|
// of conversions.
|
||||||
|
operator StoredType<T>() const {
|
||||||
|
++*conversions_;
|
||||||
|
return StoredType<T>{value_};
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_value() const {
|
||||||
|
return value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
T value_;
|
||||||
|
int *conversions_;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct StoredType {
|
||||||
|
StoredType() = default;
|
||||||
|
StoredType(T value) : value_(value) { }
|
||||||
|
|
||||||
|
friend bool operator==(StoredType const& lhs, StoredType const& rhs) {
|
||||||
|
return lhs.value_ == rhs.value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we're being passed a SearchedType<T> object, avoid the conversion
|
||||||
|
// to T. This allows testing that the transparent operations are correctly
|
||||||
|
// forwarding the SearchedType all the way to this comparison by checking
|
||||||
|
// that we didn't have a conversion when we search for a SearchedType<T>
|
||||||
|
// in a container full of StoredType<T>.
|
||||||
|
friend bool operator==(StoredType const& lhs, SearchedType<T> const& rhs) {
|
||||||
|
return lhs.value_ == rhs.get_value();
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_value() const {
|
||||||
|
return value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
T value_;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<template<class...> class UnorderedSet, class Hash, class Equal>
|
||||||
using unord_set_type = UnorderedSet<StoredType<int>, Hash, Equal>;
|
using unord_set_type = UnorderedSet<StoredType<int>, Hash, Equal>;
|
||||||
|
|
||||||
template <template <typename...> class UnorderedMap, typename Hash,
|
template<template<class...> class UnorderedMap, class Hash, class Equal>
|
||||||
typename Equal>
|
|
||||||
using unord_map_type = UnorderedMap<StoredType<int>, int, Hash, Equal>;
|
using unord_map_type = UnorderedMap<StoredType<int>, int, Hash, Equal>;
|
||||||
|
|
||||||
template <typename Container, typename... Args>
|
template<class Container>
|
||||||
void test_transparent_find(Args&&... args) {
|
void test_transparent_find(Container c) {
|
||||||
Container c{std::forward<Args>(args)...};
|
|
||||||
int conversions = 0;
|
int conversions = 0;
|
||||||
assert(c.find(SearchedType<int>(1, &conversions)) != c.end());
|
assert(c.find(SearchedType<int>(1, &conversions)) != c.end());
|
||||||
assert(c.find(SearchedType<int>(2, &conversions)) != c.end());
|
assert(c.find(SearchedType<int>(2, &conversions)) != c.end());
|
||||||
assert(conversions == 0);
|
|
||||||
assert(c.find(SearchedType<int>(3, &conversions)) == c.end());
|
assert(c.find(SearchedType<int>(3, &conversions)) == c.end());
|
||||||
assert(conversions == 0);
|
assert(conversions == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Container, typename... Args>
|
template<class Container>
|
||||||
void test_non_transparent_find(Args&&... args) {
|
void test_non_transparent_find(Container c) {
|
||||||
Container c{std::forward<Args>(args)...};
|
|
||||||
int conversions = 0;
|
int conversions = 0;
|
||||||
assert(c.find(SearchedType<int>(1, &conversions)) != c.end());
|
assert(c.find(SearchedType<int>(1, &conversions)) != c.end());
|
||||||
assert(conversions > 0);
|
assert(conversions == 1);
|
||||||
conversions = 0;
|
|
||||||
assert(c.find(SearchedType<int>(2, &conversions)) != c.end());
|
assert(c.find(SearchedType<int>(2, &conversions)) != c.end());
|
||||||
assert(conversions > 0);
|
assert(conversions == 2);
|
||||||
conversions = 0;
|
|
||||||
assert(c.find(SearchedType<int>(3, &conversions)) == c.end());
|
assert(c.find(SearchedType<int>(3, &conversions)) == c.end());
|
||||||
assert(conversions > 0);
|
assert(conversions == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Container, typename... Args>
|
template<class Container>
|
||||||
void test_transparent_count(Args&&... args) {
|
void test_transparent_count(Container c) {
|
||||||
Container c{std::forward<Args>(args)...};
|
|
||||||
int conversions = 0;
|
int conversions = 0;
|
||||||
assert(c.count(SearchedType<int>(1, &conversions)) > 0);
|
assert(c.count(SearchedType<int>(1, &conversions)) > 0);
|
||||||
assert(c.count(SearchedType<int>(2, &conversions)) > 0);
|
assert(c.count(SearchedType<int>(2, &conversions)) > 0);
|
||||||
assert(conversions == 0);
|
|
||||||
assert(c.count(SearchedType<int>(3, &conversions)) == 0);
|
assert(c.count(SearchedType<int>(3, &conversions)) == 0);
|
||||||
assert(conversions == 0);
|
assert(conversions == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Container, typename... Args>
|
template<class Container>
|
||||||
void test_non_transparent_count(Args&&... args) {
|
void test_non_transparent_count(Container c) {
|
||||||
Container c{std::forward<Args>(args)...};
|
|
||||||
int conversions = 0;
|
int conversions = 0;
|
||||||
assert(c.count(SearchedType<int>(1, &conversions)) > 0);
|
assert(c.count(SearchedType<int>(1, &conversions)) > 0);
|
||||||
assert(conversions > 0);
|
assert(conversions == 1);
|
||||||
conversions = 0;
|
|
||||||
assert(c.count(SearchedType<int>(2, &conversions)) > 0);
|
assert(c.count(SearchedType<int>(2, &conversions)) > 0);
|
||||||
assert(conversions > 0);
|
assert(conversions == 2);
|
||||||
conversions = 0;
|
|
||||||
assert(c.count(SearchedType<int>(3, &conversions)) == 0);
|
assert(c.count(SearchedType<int>(3, &conversions)) == 0);
|
||||||
assert(conversions > 0);
|
assert(conversions == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Container, typename... Args>
|
template<class Container>
|
||||||
void test_transparent_contains(Args&&... args) {
|
void test_transparent_contains(Container c) {
|
||||||
Container c{std::forward<Args>(args)...};
|
|
||||||
int conversions = 0;
|
int conversions = 0;
|
||||||
assert(c.contains(SearchedType<int>(1, &conversions)));
|
assert(c.contains(SearchedType<int>(1, &conversions)));
|
||||||
assert(c.contains(SearchedType<int>(2, &conversions)));
|
assert(c.contains(SearchedType<int>(2, &conversions)));
|
||||||
assert(conversions == 0);
|
|
||||||
assert(!c.contains(SearchedType<int>(3, &conversions)));
|
assert(!c.contains(SearchedType<int>(3, &conversions)));
|
||||||
assert(conversions == 0);
|
assert(conversions == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Container, typename... Args>
|
template<class Container>
|
||||||
void test_non_transparent_contains(Args&&... args) {
|
void test_non_transparent_contains(Container c) {
|
||||||
Container c{std::forward<Args>(args)...};
|
|
||||||
int conversions = 0;
|
int conversions = 0;
|
||||||
assert(c.contains(SearchedType<int>(1, &conversions)));
|
assert(c.contains(SearchedType<int>(1, &conversions)));
|
||||||
assert(conversions > 0);
|
assert(conversions == 1);
|
||||||
conversions = 0;
|
|
||||||
assert(c.contains(SearchedType<int>(2, &conversions)));
|
assert(c.contains(SearchedType<int>(2, &conversions)));
|
||||||
assert(conversions > 0);
|
assert(conversions == 2);
|
||||||
conversions = 0;
|
|
||||||
assert(!c.contains(SearchedType<int>(3, &conversions)));
|
assert(!c.contains(SearchedType<int>(3, &conversions)));
|
||||||
assert(conversions > 0);
|
assert(conversions == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Container, typename... Args>
|
template<class Container>
|
||||||
void test_transparent_equal_range(Args&&... args) {
|
void test_transparent_equal_range(Container c) {
|
||||||
Container c{std::forward<Args>(args)...};
|
|
||||||
int conversions = 0;
|
int conversions = 0;
|
||||||
auto iters = c.equal_range(SearchedType<int>(1, &conversions));
|
auto iters = c.equal_range(SearchedType<int>(1, &conversions));
|
||||||
assert(std::distance(iters.first, iters.second) > 0);
|
assert(std::distance(iters.first, iters.second) > 0);
|
||||||
iters = c.equal_range(SearchedType<int>(2, &conversions));
|
iters = c.equal_range(SearchedType<int>(2, &conversions));
|
||||||
assert(std::distance(iters.first, iters.second) > 0);
|
assert(std::distance(iters.first, iters.second) > 0);
|
||||||
assert(conversions == 0);
|
|
||||||
iters = c.equal_range(SearchedType<int>(3, &conversions));
|
iters = c.equal_range(SearchedType<int>(3, &conversions));
|
||||||
assert(std::distance(iters.first, iters.second) == 0);
|
assert(std::distance(iters.first, iters.second) == 0);
|
||||||
assert(conversions == 0);
|
assert(conversions == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Container, typename... Args>
|
template<class Container>
|
||||||
void test_non_transparent_equal_range(Args&&... args) {
|
void test_non_transparent_equal_range(Container c) {
|
||||||
Container c{std::forward<Args>(args)...};
|
|
||||||
int conversions = 0;
|
int conversions = 0;
|
||||||
auto iters = c.equal_range(SearchedType<int>(1, &conversions));
|
auto iters = c.equal_range(SearchedType<int>(1, &conversions));
|
||||||
assert(std::distance(iters.first, iters.second) > 0);
|
assert(std::distance(iters.first, iters.second) > 0);
|
||||||
assert(conversions > 0);
|
assert(conversions == 1);
|
||||||
conversions = 0;
|
|
||||||
iters = c.equal_range(SearchedType<int>(2, &conversions));
|
iters = c.equal_range(SearchedType<int>(2, &conversions));
|
||||||
assert(std::distance(iters.first, iters.second) > 0);
|
assert(std::distance(iters.first, iters.second) > 0);
|
||||||
assert(conversions > 0);
|
assert(conversions == 2);
|
||||||
conversions = 0;
|
|
||||||
iters = c.equal_range(SearchedType<int>(3, &conversions));
|
iters = c.equal_range(SearchedType<int>(3, &conversions));
|
||||||
assert(std::distance(iters.first, iters.second) == 0);
|
assert(std::distance(iters.first, iters.second) == 0);
|
||||||
assert(conversions > 0);
|
assert(conversions == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TEST_STD_VER > 17
|
#endif // TEST_STD_VER > 17
|
||||||
|
|
Loading…
Reference in New Issue