From d13f468c6d188fe4c17f650e0cb55e45ce969f1c Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Wed, 10 May 2023 17:04:19 -0500 Subject: human-sort: fix clang-tidy warnings about pointer arithmetic Signed-off-by: Patrick Williams Change-Id: I8122bfffaac469ee551c72632b671e8644a4da44 --- include/human_sort.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include/human_sort.hpp') diff --git a/include/human_sort.hpp b/include/human_sort.hpp index 5cb6e56283..fba98041d0 100644 --- a/include/human_sort.hpp +++ b/include/human_sort.hpp @@ -24,8 +24,8 @@ enum class ModeType inline int alphanumComp(std::string_view left, std::string_view right) { - std::string_view::const_iterator l = left.begin(); - std::string_view::const_iterator r = right.begin(); + std::string_view::const_iterator l = left.cbegin(); + std::string_view::const_iterator r = right.cbegin(); details::ModeType mode = details::ModeType::STRING; @@ -59,20 +59,20 @@ inline int alphanumComp(std::string_view left, std::string_view right) return diff; } // otherwise process the next characters - l++; - r++; + std::advance(l, 1); + std::advance(r, 1); } else // mode==NUMBER { // get the left number int lInt = 0; auto fc = std::from_chars(&(*l), &(*left.end()), lInt); - l += std::distance(l, fc.ptr); + std::advance(l, std::distance(l, fc.ptr)); // get the right number int rInt = 0; fc = std::from_chars(&(*r), &(*right.end()), rInt); - r += std::distance(r, fc.ptr); + std::advance(r, std::distance(r, fc.ptr)); // if the difference is not equal to zero, we have a comparison // result -- cgit v1.2.3