On 08/06/20 21:07 +0100, Jonathan Wakely wrote:
On 05/06/20 22:24 +0200, François Dumont via Libstdc++ wrote:
diff --git a/libstdc++-v3/include/debug/safe_iterator.tcc
b/libstdc++-v3/include/debug/safe_iterator.tcc
index 888ac803ae5..ca4e2d52d1d 100644
--- a/libstdc++-v3/include/debug/safe_iterator.tcc
+++ b/libstdc++-v3/include/debug/safe_iterator.tcc
@@ -470,6 +470,80 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return __equal_aux1(__first1, __last1, __first2);
}
+ template<typename _Ite1, typename _Seq1, typename _Cat1,
+ typename _II2>
+ int
+ __lexicographical_compare_aux(
+ const ::__gnu_debug::_Safe_iterator<_Ite1, _Seq1, _Cat1>& __first1,
+ const ::__gnu_debug::_Safe_iterator<_Ite1, _Seq1, _Cat1>& __last1,
+ _II2 __first2, _II2 __last2)
+ {
+ typename ::__gnu_debug::_Distance_traits<_Ite1>::__type __dist1;
+ __glibcxx_check_valid_range2(__first1, __last1, __dist1);
+ __glibcxx_check_valid_range(__first2, __last2);
+
+ if (__dist1.second > ::__gnu_debug::__dp_equality)
+ return std::__lexicographical_compare_aux(__first1.base(),
+ __last1.base(),
+ __first2, __last2);
+ return std::__lexicographical_compare_aux1(__first1, __last1,
+ __first2, __last2);
What's the rationale for the choice of whether to call aux or aux1
here?
It seems to be that if we know [first1, last1) is a valid range, we
use aux with the unsafe iterators (which means we do overload
resolution again for all the overloads that include _Safe_iterator,
but we know we don't have safe iterators now). Otherwise, if we don't
know it's a valid range, we call aux1 with the safe iterators.
Why don't we use aux1 in both cases?
Oh, is it because aux will still use __niter_base and so turn
__normal_iterator arguments into pointers?