First half of support for N3657; heterogenous lookups for set/multiset
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@188241 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -68,6 +68,7 @@ struct _LIBCPP_TYPE_VIS_ONLY less<void>
|
||||
template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY
|
||||
auto operator()(_T1&& __t, _T2&& __u) const
|
||||
{ return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -501,6 +502,20 @@ template <class _Tp> void cref(const _Tp&&);// = delete;
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp1, class _Tp2 = void>
|
||||
struct __is_transparent
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::is_transparent* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp1>(0)) == 1;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_FUNCTIONAL_BASE
|
||||
|
@@ -515,6 +515,7 @@ struct _LIBCPP_TYPE_VIS_ONLY plus<void>
|
||||
template <class _T1, class _T2>
|
||||
_LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const
|
||||
{ return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -537,6 +538,7 @@ struct _LIBCPP_TYPE_VIS_ONLY minus<void>
|
||||
template <class _T1, class _T2>
|
||||
_LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const
|
||||
{ return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -559,6 +561,7 @@ struct _LIBCPP_TYPE_VIS_ONLY multiplies<void>
|
||||
template <class _T1, class _T2>
|
||||
_LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const
|
||||
{ return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -581,6 +584,7 @@ struct _LIBCPP_TYPE_VIS_ONLY divides<void>
|
||||
template <class _T1, class _T2>
|
||||
_LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const
|
||||
{ return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -603,6 +607,7 @@ struct _LIBCPP_TYPE_VIS_ONLY modulus<void>
|
||||
template <class _T1, class _T2>
|
||||
_LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const
|
||||
{ return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -625,6 +630,7 @@ struct _LIBCPP_TYPE_VIS_ONLY negate<void>
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const
|
||||
{ return -_VSTD::forward<_Tp>(__x); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -647,6 +653,7 @@ struct _LIBCPP_TYPE_VIS_ONLY equal_to<void>
|
||||
template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY
|
||||
auto operator()(_T1&& __t, _T2&& __u) const
|
||||
{ return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -669,6 +676,7 @@ struct _LIBCPP_TYPE_VIS_ONLY not_equal_to<void>
|
||||
template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY
|
||||
auto operator()(_T1&& __t, _T2&& __u) const
|
||||
{ return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -691,6 +699,7 @@ struct _LIBCPP_TYPE_VIS_ONLY greater<void>
|
||||
template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY
|
||||
auto operator()(_T1&& __t, _T2&& __u) const
|
||||
{ return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -715,6 +724,7 @@ struct _LIBCPP_TYPE_VIS_ONLY greater_equal<void>
|
||||
template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY
|
||||
auto operator()(_T1&& __t, _T2&& __u) const
|
||||
{ return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -737,6 +747,7 @@ struct _LIBCPP_TYPE_VIS_ONLY less_equal<void>
|
||||
template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY
|
||||
auto operator()(_T1&& __t, _T2&& __u) const
|
||||
{ return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -759,6 +770,7 @@ struct _LIBCPP_TYPE_VIS_ONLY logical_and<void>
|
||||
template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY
|
||||
auto operator()(_T1&& __t, _T2&& __u) const
|
||||
{ return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -781,6 +793,7 @@ struct _LIBCPP_TYPE_VIS_ONLY logical_or<void>
|
||||
template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY
|
||||
auto operator()(_T1&& __t, _T2&& __u) const
|
||||
{ return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -803,6 +816,7 @@ struct _LIBCPP_TYPE_VIS_ONLY logical_not<void>
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const
|
||||
{ return !_VSTD::forward<_Tp>(__x); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -825,6 +839,7 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_and<void>
|
||||
template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY
|
||||
auto operator()(_T1&& __t, _T2&& __u) const
|
||||
{ return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -847,6 +862,7 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_or<void>
|
||||
template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY
|
||||
auto operator()(_T1&& __t, _T2&& __u) const
|
||||
{ return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -869,6 +885,7 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_xor<void>
|
||||
template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY
|
||||
auto operator()(_T1&& __t, _T2&& __u) const
|
||||
{ return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -887,6 +904,7 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_not<void>
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const
|
||||
{ return ~_VSTD::forward<_Tp>(__x); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
128
include/set
128
include/set
@@ -129,13 +129,33 @@ public:
|
||||
// set operations:
|
||||
iterator find(const key_type& k);
|
||||
const_iterator find(const key_type& k) const;
|
||||
template<typename K>
|
||||
iterator find(const K& x);
|
||||
template<typename K>
|
||||
const_iterator find(const K& x) const; // C++14
|
||||
template<typename K>
|
||||
size_type count(const K& x) const; // C++14
|
||||
|
||||
size_type count(const key_type& k) const;
|
||||
iterator lower_bound(const key_type& k);
|
||||
const_iterator lower_bound(const key_type& k) const;
|
||||
template<typename K>
|
||||
iterator lower_bound(const K& x); // C++14
|
||||
template<typename K>
|
||||
const_iterator lower_bound(const K& x) const; // C++14
|
||||
|
||||
iterator upper_bound(const key_type& k);
|
||||
const_iterator upper_bound(const key_type& k) const;
|
||||
template<typename K>
|
||||
iterator upper_bound(const K& x); // C++14
|
||||
template<typename K>
|
||||
const_iterator upper_bound(const K& x) const; // C++14
|
||||
pair<iterator,iterator> equal_range(const key_type& k);
|
||||
pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
|
||||
template<typename K>
|
||||
pair<iterator,iterator> equal_range(const K& x); // C++14
|
||||
template<typename K>
|
||||
pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
|
||||
};
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
@@ -285,13 +305,32 @@ public:
|
||||
// set operations:
|
||||
iterator find(const key_type& k);
|
||||
const_iterator find(const key_type& k) const;
|
||||
template<typename K>
|
||||
iterator find(const K& x);
|
||||
template<typename K>
|
||||
const_iterator find(const K& x) const; // C++14
|
||||
|
||||
size_type count(const key_type& k) const;
|
||||
iterator lower_bound(const key_type& k);
|
||||
const_iterator lower_bound(const key_type& k) const;
|
||||
template<typename K>
|
||||
iterator lower_bound(const K& x); // C++14
|
||||
template<typename K>
|
||||
const_iterator lower_bound(const K& x) const; // C++14
|
||||
|
||||
iterator upper_bound(const key_type& k);
|
||||
const_iterator upper_bound(const key_type& k) const;
|
||||
template<typename K>
|
||||
iterator upper_bound(const K& x); // C++14
|
||||
template<typename K>
|
||||
const_iterator upper_bound(const K& x) const; // C++14
|
||||
|
||||
pair<iterator,iterator> equal_range(const key_type& k);
|
||||
pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
|
||||
template<typename K>
|
||||
pair<iterator,iterator> equal_range(const K& x); // C++14
|
||||
template<typename K>
|
||||
pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
|
||||
};
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
@@ -579,6 +618,17 @@ public:
|
||||
iterator find(const key_type& __k) {return __tree_.find(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
|
||||
find(const _K2& __k) {return __tree_.find(__k);}
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
|
||||
find(const _K2& __k) const {return __tree_.find(__k);}
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type count(const key_type& __k) const
|
||||
{return __tree_.__count_unique(__k);}
|
||||
@@ -588,18 +638,51 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator lower_bound(const key_type& __k) const
|
||||
{return __tree_.lower_bound(__k);}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
|
||||
lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
|
||||
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
|
||||
lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator upper_bound(const key_type& __k)
|
||||
{return __tree_.upper_bound(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator upper_bound(const key_type& __k) const
|
||||
{return __tree_.upper_bound(__k);}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
|
||||
upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
|
||||
upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator,iterator> equal_range(const key_type& __k)
|
||||
{return __tree_.__equal_range_unique(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
|
||||
{return __tree_.__equal_range_unique(__k);}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
|
||||
equal_range(const _K2& __k) {return __tree_.__equal_range_unique(__k);}
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
|
||||
equal_range(const _K2& __k) const {return __tree_.__equal_range_unique(__k);}
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
@@ -917,27 +1000,72 @@ public:
|
||||
iterator find(const key_type& __k) {return __tree_.find(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
|
||||
find(const _K2& __k) {return __tree_.find(__k);}
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
|
||||
find(const _K2& __k) const {return __tree_.find(__k);}
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type count(const key_type& __k) const
|
||||
{return __tree_.__count_multi(__k);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator lower_bound(const key_type& __k)
|
||||
{return __tree_.lower_bound(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator lower_bound(const key_type& __k) const
|
||||
{return __tree_.lower_bound(__k);}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
|
||||
lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
|
||||
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
|
||||
lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator upper_bound(const key_type& __k)
|
||||
{return __tree_.upper_bound(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator upper_bound(const key_type& __k) const
|
||||
{return __tree_.upper_bound(__k);}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
|
||||
upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
|
||||
upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator,iterator> equal_range(const key_type& __k)
|
||||
{return __tree_.__equal_range_multi(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
|
||||
{return __tree_.__equal_range_multi(__k);}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
|
||||
equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
|
||||
template <typename _K2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
|
||||
equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
Reference in New Issue
Block a user