Don't use default-constructed KeyNodeCompare to support stateful comparison objects

This commit is contained in:
Ion Gaztañaga
2024-06-05 11:20:11 +02:00
parent 24c978b550
commit 13be16a0c8

View File

@ -1240,13 +1240,13 @@ class tree
BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
typename dtl::enable_if_transparent<key_compare, K, iterator>::type
find(const K& k)
{ return iterator(this->icont().find(k, KeyNodeCompare())); }
{ return iterator(this->icont().find(k, KeyNodeCompare(key_comp()))); }
template <class K>
BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
typename dtl::enable_if_transparent<key_compare, K, const_iterator>::type
find(const K& k) const
{ return const_iterator(this->non_const_icont().find(k, KeyNodeCompare())); }
{ return const_iterator(this->non_const_icont().find(k, KeyNodeCompare(key_comp()))); }
BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
size_type count(const key_type& k) const
@ -1256,7 +1256,7 @@ class tree
BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
typename dtl::enable_if_transparent<key_compare, K, size_type>::type
count(const K& k) const
{ return size_type(this->icont().count(k, KeyNodeCompare())); }
{ return size_type(this->icont().count(k, KeyNodeCompare(key_comp()))); }
BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
bool contains(const key_type& x) const
@ -1280,13 +1280,13 @@ class tree
BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
typename dtl::enable_if_transparent<key_compare, K, iterator>::type
lower_bound(const K& k)
{ return iterator(this->icont().lower_bound(k, KeyNodeCompare())); }
{ return iterator(this->icont().lower_bound(k, KeyNodeCompare(key_comp()))); }
template <class K>
BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
typename dtl::enable_if_transparent<key_compare, K, const_iterator>::type
lower_bound(const K& k) const
{ return const_iterator(this->non_const_icont().lower_bound(k, KeyNodeCompare())); }
{ return const_iterator(this->non_const_icont().lower_bound(k, KeyNodeCompare(key_comp()))); }
BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
iterator upper_bound(const key_type& k)
@ -1300,13 +1300,13 @@ class tree
BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
typename dtl::enable_if_transparent<key_compare, K, iterator>::type
upper_bound(const K& k)
{ return iterator(this->icont().upper_bound(k, KeyNodeCompare())); }
{ return iterator(this->icont().upper_bound(k, KeyNodeCompare(key_comp()))); }
template <class K>
BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
typename dtl::enable_if_transparent<key_compare, K, const_iterator>::type
upper_bound(const K& k) const
{ return const_iterator(this->non_const_icont().upper_bound(k, KeyNodeCompare())); }
{ return const_iterator(this->non_const_icont().upper_bound(k, KeyNodeCompare(key_comp()))); }
BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
std::pair<iterator,iterator> equal_range(const key_type& k)
@ -1330,7 +1330,7 @@ class tree
equal_range(const K& k)
{
std::pair<iiterator, iiterator> ret =
this->icont().equal_range(k, KeyNodeCompare());
this->icont().equal_range(k, KeyNodeCompare(key_comp()));
return std::pair<iterator,iterator>(iterator(ret.first), iterator(ret.second));
}
@ -1340,7 +1340,7 @@ class tree
equal_range(const K& k) const
{
std::pair<iiterator, iiterator> ret =
this->non_const_icont().equal_range(k, KeyNodeCompare());
this->non_const_icont().equal_range(k, KeyNodeCompare(key_comp()));
return std::pair<const_iterator,const_iterator>
(const_iterator(ret.first), const_iterator(ret.second));
}
@ -1368,7 +1368,7 @@ class tree
lower_bound_range(const K& k)
{
std::pair<iiterator, iiterator> ret =
this->icont().lower_bound_range(k, KeyNodeCompare());
this->icont().lower_bound_range(k, KeyNodeCompare(key_comp()));
return std::pair<iterator,iterator>(iterator(ret.first), iterator(ret.second));
}
@ -1378,7 +1378,7 @@ class tree
lower_bound_range(const K& k) const
{
std::pair<iiterator, iiterator> ret =
this->non_const_icont().lower_bound_range(k, KeyNodeCompare());
this->non_const_icont().lower_bound_range(k, KeyNodeCompare(key_comp()));
return std::pair<const_iterator,const_iterator>
(const_iterator(ret.first), const_iterator(ret.second));
}