Make associative container operators inline friend

François Dumont frs.dumont@gmail.com
Thu Oct 4 05:38:00 GMT 2018


Here is the cleanup version.

     * include/bits/stl_tree.h
     (_Rb_tree_iterator<>::operator==): Make inline friend.
     (_Rb_tree_iterator<>::operator!=): Likewise.
     (_Rb_tree_const_iterator<>::operator==): Likewise.
     (_Rb_tree_const_iterator<>::operator!=): Likewise.
     (operator==(const _Rb_tree_iterator<>&,
     const _Rb_tree_const_iterator&)): Remove.
     (operator!=(const _Rb_tree_iterator<>&,
     const _Rb_tree_const_iterator&)): Remove.
     (operator==(const _Rb_tree<>&, const _Rb_tree<>&)): Make inline friend.
     (operator<(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise.
     (operator!=(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise and 
deprecate.
     (operator>(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise.
     (operator<=(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise.
     (operator>=(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise.
     * include/debug/map.h (map<>::erase(const_iterator, const_iterator)):
     Compare __victim with _Base::cend().
     * include/debug/multimap.h (multimap<>::erase(const_iterator, 
const_iterator)):
     Likewise.
     * include/debug/set.h (set<>::erase(const_iterator, const_iterator)):
     Compare __victim with _Base::cend().
     * include/debug/multiset.h (multiset<>::erase(const_iterator, 
const_iterator)):
     Likewise.

Tested under Linux x86_64.

Ok to commit ?

François

On 10/03/2018 12:08 PM, Jonathan Wakely wrote:
>> I consider the Table 83 - Container requirements where it is only 
>> saying that a == b should be well defined without namespace 
>> consideration. But I won't argue on Standard details with you, I'll 
>> revert that part.
>
> The table says what they mean, but the synopses for <map> and <set>
> also show declarations for those operators at namespace scope.
>
>>> As far as I can tell, we only every use __x._M_t < __y._M_t and
>>> __x._M_t == __y._M_t, so don't need anything else.
>>
>> For sure we don't use those for associative containers operators. I 
>> guess they have been added for consistency with Standard containers. 
>> There are here for a long time, do you want to remove them now ? I 
>> can add this cleanup in my patch if you want.
>
> Maybe we should deprecate them first. So please make them inline
> friends (as for == and <) and add __attribute__((__deprecated__)).
> I'll add something to the release notes for gcc-9 saying they're
> deprecated. If nobody complains we can remove them for gcc-10 or
> gcc-11.
>
>
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: assoc_conts_inline_friend_oper.patch
Type: text/x-patch
Size: 7092 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20181004/418514d0/attachment.bin>


More information about the Libstdc++ mailing list