Skip to content

Commit

Permalink
selection of proper comparsion functions was problematic in MSVC and …
Browse files Browse the repository at this point in the history
…due multiple options it failed (fix for #338)
  • Loading branch information
hanickadot committed Feb 8, 2025
1 parent 6de31ef commit a9418a5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
7 changes: 3 additions & 4 deletions include/ctre/utf8.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ struct utf8_iterator {
friend constexpr auto operator==(self_type, const char8_t * other_ptr) noexcept {
return *other_ptr == char8_t{0};
}

#if __cpp_impl_three_way_comparison < 201907L
friend constexpr auto operator!=(self_type, const char8_t * other_ptr) noexcept {
return *other_ptr != char8_t{0};
}

#if __cpp_impl_three_way_comparison < 201907L
friend constexpr auto operator==(const char8_t * other_ptr, self_type) noexcept {
return *other_ptr == char8_t{0};
}
Expand All @@ -61,7 +60,7 @@ struct utf8_iterator {

const char8_t * ptr{nullptr};
const char8_t * end{nullptr};
#if __cpp_impl_three_way_comparison < 201907L
constexpr friend bool operator!=(const utf8_iterator & lhs, sentinel) {
return lhs.ptr < lhs.end;
}
Expand All @@ -73,7 +72,7 @@ struct utf8_iterator {
constexpr friend bool operator!=(const utf8_iterator & lhs, const utf8_iterator & rhs) {
return lhs.ptr != rhs.ptr;
}

#endif
constexpr friend bool operator==(const utf8_iterator & lhs, sentinel) {
return lhs.ptr >= lhs.end;
}
Expand Down
7 changes: 3 additions & 4 deletions single-header/ctre-unicode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3125,12 +3125,11 @@ struct utf8_iterator {
friend constexpr auto operator==(self_type, const char8_t * other_ptr) noexcept {
return *other_ptr == char8_t{0};
}

#if __cpp_impl_three_way_comparison < 201907L
friend constexpr auto operator!=(self_type, const char8_t * other_ptr) noexcept {
return *other_ptr != char8_t{0};
}

#if __cpp_impl_three_way_comparison < 201907L
friend constexpr auto operator==(const char8_t * other_ptr, self_type) noexcept {
return *other_ptr == char8_t{0};
}
Expand All @@ -3143,7 +3142,7 @@ struct utf8_iterator {

const char8_t * ptr{nullptr};
const char8_t * end{nullptr};
#if __cpp_impl_three_way_comparison < 201907L
constexpr friend bool operator!=(const utf8_iterator & lhs, sentinel) {
return lhs.ptr < lhs.end;
}
Expand All @@ -3155,7 +3154,7 @@ struct utf8_iterator {
constexpr friend bool operator!=(const utf8_iterator & lhs, const utf8_iterator & rhs) {
return lhs.ptr != rhs.ptr;
}

#endif
constexpr friend bool operator==(const utf8_iterator & lhs, sentinel) {
return lhs.ptr >= lhs.end;
}
Expand Down
7 changes: 3 additions & 4 deletions single-header/ctre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3122,12 +3122,11 @@ struct utf8_iterator {
friend constexpr auto operator==(self_type, const char8_t * other_ptr) noexcept {
return *other_ptr == char8_t{0};
}

#if __cpp_impl_three_way_comparison < 201907L
friend constexpr auto operator!=(self_type, const char8_t * other_ptr) noexcept {
return *other_ptr != char8_t{0};
}

#if __cpp_impl_three_way_comparison < 201907L
friend constexpr auto operator==(const char8_t * other_ptr, self_type) noexcept {
return *other_ptr == char8_t{0};
}
Expand All @@ -3140,7 +3139,7 @@ struct utf8_iterator {

const char8_t * ptr{nullptr};
const char8_t * end{nullptr};
#if __cpp_impl_three_way_comparison < 201907L
constexpr friend bool operator!=(const utf8_iterator & lhs, sentinel) {
return lhs.ptr < lhs.end;
}
Expand All @@ -3152,7 +3151,7 @@ struct utf8_iterator {
constexpr friend bool operator!=(const utf8_iterator & lhs, const utf8_iterator & rhs) {
return lhs.ptr != rhs.ptr;
}

#endif
constexpr friend bool operator==(const utf8_iterator & lhs, sentinel) {
return lhs.ptr >= lhs.end;
}
Expand Down

0 comments on commit a9418a5

Please sign in to comment.