[PATCH] lexicographical_comparison enhancements
François Dumont
frs.dumont@gmail.com
Mon Sep 16 19:57:00 GMT 2019
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lexicographical_cmp.patch
Type: text/x-patch
Size: 20953 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20190916/c62b8cf0/attachment.bin>
More information about the Libstdc++
mailing list