[PATCH] lexicographical_comparison enhancements

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] lexicographical_comparison enhancements

François Dumont-2
Hi

This is the next part of:

https://gcc.gnu.org/ml/libstdc++/2019-09/msg00048.html

This time it is to improve behavior of std::lexicographical_compare for
deque or safe iterators.

To do so I had to make lc internal implementation return int rather than
bool otherwise it is impossible to have a chunk base approach for the
deque iterators. I'm surprised that std::lexicographical_compare returns
a bool by the way, usually comparisons return int.

Tested under Linux x86_64 normal and debug modes.

Ok to commit ?


     * include/bits/stl_algobase.h
     (__lexicographical_compare_impl): Return int.
     (__lexicographical_compare::__lc): Likewise.
     (__lexicographical_compare_aux1(_II1, _II1, _II2, _II2)): New.
     (__lexicographical_compare_aux1(_Deque_iterator<>, _Deque_iterator<>,
     _II2, _II2)): New.
     (__lexicographical_compare_aux1(_II1, _II1,
     _Deque_iterator<>, _Deque_iterator<>)): New.
     (__lexicographical_compare_aux1(_Deque_iterator<>, _Deque_iterator<>,
     _Deque_iterator<>, _Deque_iterator<>)): New.
     (__lexicographical_compare_aux): Adapt, call later.
     (__lexicographical_compare_aux(_Safe_iterator<>, _Safe_iterator<>,
     _II2, _II2)): New.
     (__lexicographical_compare_aux(_II1, _II1,
     _Safe_iterator<>, _Safe_iterator<>)): New.
     (__lexicographical_compare_aux(_Safe_iterator<>, _Safe_iterator<>,
     _Safe_iterator<>, _Safe_iterator<>)): New.
     (std::lexicographical_compare): Adapt, call later.
     * include/bits/stl_deque.h (__lexicographical_compare_aux1): New
     declarations.
     * include/bits/deque.tcc (__lex_cmp_dit): New.
     (__lexicographical_compare_aux1): New definitions.
     * include/debug/safe_iterator.h (__lexicographical_compare_aux): New.
     * testsuite/25_algorithms/lexicographical_compare/1.cc (test6, test7):
     New.
     * testsuite/25_algorithms/lexicographical_compare/deque_iterators/1.cc:
     New.

François


lexicographical_cmp.patch (21K) Download Attachment