diff options
author | Patrick Williams <patrick@stwcx.xyz> | 2023-05-11 01:04:19 +0300 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2023-05-11 01:04:22 +0300 |
commit | d13f468c6d188fe4c17f650e0cb55e45ce969f1c (patch) | |
tree | cf3197fa45e9228cb8e5879a062812b053d24312 /include/human_sort.hpp | |
parent | 89492a157c9cf972b342421e24d41fd382510251 (diff) | |
download | bmcweb-d13f468c6d188fe4c17f650e0cb55e45ce969f1c.tar.xz |
human-sort: fix clang-tidy warnings about pointer arithmetic
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I8122bfffaac469ee551c72632b671e8644a4da44
Diffstat (limited to 'include/human_sort.hpp')
-rw-r--r-- | include/human_sort.hpp | 12 |
1 files changed, 6 insertions, 6 deletions
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 |