From e8c235b62e6ca50363eec4203e0eaf46ad9bea3e Mon Sep 17 00:00:00 2001 From: Vojtech Horky Date: Sun, 23 Jul 2023 17:35:35 +0200 Subject: [PATCH] C++: expand loop if types are different --- uspace/lib/cpp/include/__bits/algorithm.hpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/uspace/lib/cpp/include/__bits/algorithm.hpp b/uspace/lib/cpp/include/__bits/algorithm.hpp index f34b3c4cd..25b2d0bc3 100644 --- a/uspace/lib/cpp/include/__bits/algorithm.hpp +++ b/uspace/lib/cpp/include/__bits/algorithm.hpp @@ -1109,14 +1109,22 @@ namespace std InputIterator2 first2, InputIterator2 last2) { + while ((first1 != last1) && (first2 != last2)) + { + if (*first1 < *first2) + return true; + if (*first2 < *first1) + return false; + + ++first1; + ++first2; + } + /** - * *first1 and *first2 can have different types - * so we use a transparent comparator. + * Up until now they are same, so we have to check + * if we reached the end on one. */ - return lexicographical_compare( - first1, last1, first2, last2, - less{} - ); + return (first1 == last1) && (first2 != last2); } template -- 2.11.4.GIT