Skip to content

Commit 84b7897

Browse files
Patch iterator walking past end (hanickadot#140)
* Patch iterator walking past end Resolves hanickadot#139 * Update evaluation.hpp reformat and spell it a bit differently Co-authored-by: Hana Dusíková <[email protected]>
1 parent a45176f commit 84b7897

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

include/ctre/evaluation.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,10 @@ template <typename Iterator> struct string_match_result {
139139
};
140140

141141
template <typename CharT, typename Iterator, typename EndIterator> constexpr CTRE_FORCE_INLINE bool compare_character(CharT c, Iterator & it, const EndIterator & end) {
142-
bool same = ((it != end) && (*it == c));
143-
++it;
144-
return same;
142+
if (it != end) {
143+
return *it++ == c;
144+
}
145+
return false;
145146
}
146147

147148
template <auto... String, size_t... Idx, typename Iterator, typename EndIterator> constexpr CTRE_FORCE_INLINE string_match_result<Iterator> evaluate_match_string(Iterator current, [[maybe_unused]] const EndIterator end, std::index_sequence<Idx...>) noexcept {

0 commit comments

Comments
 (0)