Skip to content

[libc++] Simplify overload sets where C::iterator == C::const_iterator #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 0 additions & 76 deletions libcxx/include/set
Original file line number Diff line number Diff line change
Expand Up @@ -741,24 +741,14 @@ public:
static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
}

_LIBCPP_INLINE_VISIBILITY
iterator begin() _NOEXCEPT {return __tree_.begin();}
_LIBCPP_INLINE_VISIBILITY
const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
_LIBCPP_INLINE_VISIBILITY
iterator end() _NOEXCEPT {return __tree_.end();}
_LIBCPP_INLINE_VISIBILITY
const_iterator end() const _NOEXCEPT {return __tree_.end();}

_LIBCPP_INLINE_VISIBILITY
reverse_iterator rbegin() _NOEXCEPT
{return reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator rbegin() const _NOEXCEPT
{return const_reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY
reverse_iterator rend() _NOEXCEPT
{return reverse_iterator(begin());}
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator rend() const _NOEXCEPT
{return const_reverse_iterator(begin());}
Expand Down Expand Up @@ -916,14 +906,8 @@ public:

// set operations:
_LIBCPP_INLINE_VISIBILITY
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 >= 14
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
iterator
find(const _K2& __k) {return __tree_.find(__k);}
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
const_iterator
Expand All @@ -950,51 +934,29 @@ public:
#endif // _LIBCPP_STD_VER >= 20

_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 >= 14
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
iterator
lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}

template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
const_iterator
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 >= 14
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
iterator
upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
const_iterator
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 >= 14
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
pair<iterator,iterator>
equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
pair<const_iterator,const_iterator>
Expand Down Expand Up @@ -1332,24 +1294,14 @@ public:
static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
}

_LIBCPP_INLINE_VISIBILITY
iterator begin() _NOEXCEPT {return __tree_.begin();}
_LIBCPP_INLINE_VISIBILITY
const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
_LIBCPP_INLINE_VISIBILITY
iterator end() _NOEXCEPT {return __tree_.end();}
_LIBCPP_INLINE_VISIBILITY
const_iterator end() const _NOEXCEPT {return __tree_.end();}

_LIBCPP_INLINE_VISIBILITY
reverse_iterator rbegin() _NOEXCEPT
{return reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator rbegin() const _NOEXCEPT
{return const_reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY
reverse_iterator rend() _NOEXCEPT
{return reverse_iterator(begin());}
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator rend() const _NOEXCEPT
{return const_reverse_iterator(begin());}
Expand Down Expand Up @@ -1507,14 +1459,8 @@ public:

// set operations:
_LIBCPP_INLINE_VISIBILITY
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 >= 14
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
iterator
find(const _K2& __k) {return __tree_.find(__k);}
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
const_iterator
Expand All @@ -1541,51 +1487,29 @@ public:
#endif // _LIBCPP_STD_VER >= 20

_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 >= 14
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
iterator
lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}

template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
const_iterator
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 >= 14
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
iterator
upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
const_iterator
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 >= 14
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
pair<iterator,iterator>
equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
_LIBCPP_INLINE_VISIBILITY
pair<const_iterator,const_iterator>
Expand Down
40 changes: 0 additions & 40 deletions libcxx/include/unordered_set
Original file line number Diff line number Diff line change
Expand Up @@ -740,10 +740,6 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type max_size() const _NOEXCEPT {return __table_.max_size();}

_LIBCPP_INLINE_VISIBILITY
iterator begin() _NOEXCEPT {return __table_.begin();}
_LIBCPP_INLINE_VISIBILITY
iterator end() _NOEXCEPT {return __table_.end();}
_LIBCPP_INLINE_VISIBILITY
const_iterator begin() const _NOEXCEPT {return __table_.begin();}
_LIBCPP_INLINE_VISIBILITY
Expand Down Expand Up @@ -880,14 +876,9 @@ public:
_LIBCPP_INLINE_VISIBILITY
key_equal key_eq() const {return __table_.key_eq();}

_LIBCPP_INLINE_VISIBILITY
iterator find(const key_type& __k) {return __table_.find(__k);}
_LIBCPP_INLINE_VISIBILITY
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
#if _LIBCPP_STD_VER >= 20
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
_LIBCPP_INLINE_VISIBILITY
iterator 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>
_LIBCPP_INLINE_VISIBILITY
const_iterator find(const _K2& __k) const {return __table_.find(__k);}
Expand All @@ -911,18 +902,11 @@ public:
#endif // _LIBCPP_STD_VER >= 20

_LIBCPP_INLINE_VISIBILITY
pair<iterator, iterator> equal_range(const key_type& __k)
{return __table_.__equal_range_unique(__k);}
_LIBCPP_INLINE_VISIBILITY
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
{return __table_.__equal_range_unique(__k);}
#if _LIBCPP_STD_VER >= 20
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
_LIBCPP_INLINE_VISIBILITY
pair<iterator, iterator> equal_range(const _K2& __k)
{return __table_.__equal_range_unique(__k);}
template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
_LIBCPP_INLINE_VISIBILITY
pair<const_iterator, const_iterator> equal_range(const _K2& __k) const
{return __table_.__equal_range_unique(__k);}
#endif // _LIBCPP_STD_VER >= 20
Expand All @@ -937,10 +921,6 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}

_LIBCPP_INLINE_VISIBILITY
local_iterator begin(size_type __n) {return __table_.begin(__n);}
_LIBCPP_INLINE_VISIBILITY
local_iterator end(size_type __n) {return __table_.end(__n);}
_LIBCPP_INLINE_VISIBILITY
const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);}
_LIBCPP_INLINE_VISIBILITY
Expand Down Expand Up @@ -1429,10 +1409,6 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type max_size() const _NOEXCEPT {return __table_.max_size();}

_LIBCPP_INLINE_VISIBILITY
iterator begin() _NOEXCEPT {return __table_.begin();}
_LIBCPP_INLINE_VISIBILITY
iterator end() _NOEXCEPT {return __table_.end();}
_LIBCPP_INLINE_VISIBILITY
const_iterator begin() const _NOEXCEPT {return __table_.begin();}
_LIBCPP_INLINE_VISIBILITY
Expand Down Expand Up @@ -1566,14 +1542,9 @@ public:
_LIBCPP_INLINE_VISIBILITY
key_equal key_eq() const {return __table_.key_eq();}

_LIBCPP_INLINE_VISIBILITY
iterator find(const key_type& __k) {return __table_.find(__k);}
_LIBCPP_INLINE_VISIBILITY
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
#if _LIBCPP_STD_VER >= 20
template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
_LIBCPP_INLINE_VISIBILITY
iterator 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>
_LIBCPP_INLINE_VISIBILITY
const_iterator find(const _K2& __k) const {return __table_.find(__k);}
Expand All @@ -1597,18 +1568,11 @@ public:
#endif // _LIBCPP_STD_VER >= 20

_LIBCPP_INLINE_VISIBILITY
pair<iterator, iterator> equal_range(const key_type& __k)
{return __table_.__equal_range_multi(__k);}
_LIBCPP_INLINE_VISIBILITY
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
{return __table_.__equal_range_multi(__k);}
#if _LIBCPP_STD_VER >= 20
template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
_LIBCPP_INLINE_VISIBILITY
pair<iterator, iterator> equal_range(const _K2& __k)
{return __table_.__equal_range_multi(__k);}
template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
_LIBCPP_INLINE_VISIBILITY
pair<const_iterator, const_iterator> equal_range(const _K2& __k) const
{return __table_.__equal_range_multi(__k);}
#endif // _LIBCPP_STD_VER >= 20
Expand All @@ -1623,10 +1587,6 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}

_LIBCPP_INLINE_VISIBILITY
local_iterator begin(size_type __n) {return __table_.begin(__n);}
_LIBCPP_INLINE_VISIBILITY
local_iterator end(size_type __n) {return __table_.end(__n);}
_LIBCPP_INLINE_VISIBILITY
const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);}
_LIBCPP_INLINE_VISIBILITY
Expand Down