@@ -3001,6 +3001,8 @@ template <size_t Id, typename Name = void> struct captured_content {
30013001 #if __cpp_char8_t >= 201811
30023002 if constexpr (std::is_same_v<Iterator, utf8_iterator>) {
30033003 return static_cast<size_t>(std::distance(_begin.ptr, _end.ptr));
3004+ } else {
3005+ return static_cast<size_t>(std::distance(begin(), end()));
30043006 }
30053007 #endif
30063008 return static_cast<size_t>(std::distance(begin(), end()));
@@ -3028,6 +3030,8 @@ template <size_t Id, typename Name = void> struct captured_content {
30283030 #if __cpp_char8_t >= 201811
30293031 if constexpr (std::is_same_v<Iterator, utf8_iterator>) {
30303032 return std::basic_string<char_type>(data_unsafe(), static_cast<size_t>(unit_size()));
3033+ } else {
3034+ return std::basic_string<char_type>(begin(), end());
30313035 }
30323036 #endif
30333037 return std::basic_string<char_type>(begin(), end());
@@ -4240,46 +4244,46 @@ constexpr CTRE_FORCE_INLINE R evaluate(const Iterator begin, Iterator current, c
42404244
42414245 if constexpr (B != 0 && A > B) {
42424246 return not_matched;
4243- }
4244-
4245- const Iterator backup_current = current;
4247+ } else {
4248+ const Iterator backup_current = current;
42464249
4247- size_t i{0};
4250+ size_t i{0};
42484251
4249- while (less_than<A>(i)) {
4250- auto outer_result = evaluate(begin, current, end, not_empty_match(f), captures, ctll::list<Content..., end_cycle_mark>());
4252+ while (less_than<A>(i)) {
4253+ auto outer_result = evaluate(begin, current, end, not_empty_match(f), captures, ctll::list<Content..., end_cycle_mark>());
42514254
4252- if (!outer_result) return not_matched;
4255+ if (!outer_result) return not_matched;
42534256
4254- captures = outer_result.unmatch();
4255- current = outer_result.get_end_position();
4257+ captures = outer_result.unmatch();
4258+ current = outer_result.get_end_position();
42564259
4257- ++i;
4258- }
4260+ ++i;
4261+ }
42594262
4260- if (auto outer_result = evaluate(begin, current, end, consumed_something(f, backup_current != current), captures, ctll::list<Tail...>())) {
4261- return outer_result;
4262- }
4263+ if (auto outer_result = evaluate(begin, current, end, consumed_something(f, backup_current != current), captures, ctll::list<Tail...>())) {
4264+ return outer_result;
4265+ }
42634266
4264- while (less_than_or_infinite<B>(i)) {
4265- auto inner_result = evaluate(begin, current, end, not_empty_match(f), captures, ctll::list<Content..., end_cycle_mark>());
4267+ while (less_than_or_infinite<B>(i)) {
4268+ auto inner_result = evaluate(begin, current, end, not_empty_match(f), captures, ctll::list<Content..., end_cycle_mark>());
42664269
4267- if (!inner_result) return not_matched;
4270+ if (!inner_result) return not_matched;
42684271
4269- auto outer_result = evaluate(begin, inner_result.get_end_position(), end, consumed_something(f), inner_result.unmatch(), ctll::list<Tail...>());
4272+ auto outer_result = evaluate(begin, inner_result.get_end_position(), end, consumed_something(f), inner_result.unmatch(), ctll::list<Tail...>());
42704273
4271- if (outer_result) {
4272- return outer_result;
4273- }
4274+ if (outer_result) {
4275+ return outer_result;
4276+ }
42744277
4275- captures = inner_result.unmatch();
4276- current = inner_result.get_end_position();
4278+ captures = inner_result.unmatch();
4279+ current = inner_result.get_end_position();
42774280
4278- ++i;
4279- }
4281+ ++i;
4282+ }
42804283
4281- // rest of regex
4282- return evaluate(begin, current, end, consumed_something(f), captures, ctll::list<Tail...>());
4284+ // rest of regex
4285+ return evaluate(begin, current, end, consumed_something(f), captures, ctll::list<Tail...>());
4286+ }
42834287}
42844288
42854289// possessive repeat
@@ -4288,24 +4292,24 @@ constexpr CTRE_FORCE_INLINE R evaluate(const Iterator begin, Iterator current, c
42884292
42894293 if constexpr ((B != 0) && (A > B)) {
42904294 return not_matched;
4291- }
4292-
4293- const auto backup_current = current;
4295+ } else {
4296+ const auto backup_current = current;
42944297
4295- for (size_t i{0}; less_than_or_infinite<B>(i); ++i) {
4296- // try as many of inner as possible and then try outer once
4297- auto inner_result = evaluate(begin, current, end, not_empty_match(f), captures, ctll::list<Content..., end_cycle_mark>());
4298+ for (size_t i{0}; less_than_or_infinite<B>(i); ++i) {
4299+ // try as many of inner as possible and then try outer once
4300+ auto inner_result = evaluate(begin, current, end, not_empty_match(f), captures, ctll::list<Content..., end_cycle_mark>());
42984301
4299- if (!inner_result) {
4300- if (!less_than<A>(i)) break;
4301- return not_matched;
4302- }
4302+ if (!inner_result) {
4303+ if (!less_than<A>(i)) break;
4304+ return not_matched;
4305+ }
43034306
4304- captures = inner_result.unmatch();
4305- current = inner_result.get_end_position();
4306- }
4307+ captures = inner_result.unmatch();
4308+ current = inner_result.get_end_position();
4309+ }
43074310
4308- return evaluate(begin, current, end, consumed_something(f, backup_current != current), captures, ctll::list<Tail...>());
4311+ return evaluate(begin, current, end, consumed_something(f, backup_current != current), captures, ctll::list<Tail...>());
4312+ }
43094313}
43104314
43114315// (gready) repeat
@@ -4355,31 +4359,32 @@ constexpr CTRE_FORCE_INLINE R evaluate(const Iterator begin, Iterator current, c
43554359 }
43564360
43574361#ifndef CTRE_DISABLE_GREEDY_OPT
4358- if constexpr (!collides(calculate_first(Content{}...), calculate_first(Tail{}...))) {
4362+ else if constexpr (!collides(calculate_first(Content{}...), calculate_first(Tail{}...))) {
43594363 return evaluate(begin, current, end, f, captures, ctll::list<possessive_repeat<A,B,Content...>, Tail...>());
43604364 }
43614365#endif
4362-
4363- // A..B
4364- size_t i{0};
4365- while (less_than<A>(i)) {
4366- auto inner_result = evaluate(begin, current, end, not_empty_match(f), captures, ctll::list<Content..., end_cycle_mark>());
4366+ else {
4367+ // A..B
4368+ size_t i{0};
4369+ while (less_than<A>(i)) {
4370+ auto inner_result = evaluate(begin, current, end, not_empty_match(f), captures, ctll::list<Content..., end_cycle_mark>());
43674371
4368- if (!inner_result) return not_matched;
4372+ if (!inner_result) return not_matched;
43694373
4370- captures = inner_result.unmatch();
4371- current = inner_result.get_end_position();
4374+ captures = inner_result.unmatch();
4375+ current = inner_result.get_end_position();
43724376
4373- ++i;
4374- }
4377+ ++i;
4378+ }
43754379
43764380#ifdef CTRE_MSVC_GREEDY_WORKAROUND
4377- R result;
4378- evaluate_recursive(result, i, begin, current, end, f, captures, stack);
4379- return result;
4381+ R result;
4382+ evaluate_recursive(result, i, begin, current, end, f, captures, stack);
4383+ return result;
43804384#else
4381- return evaluate_recursive(i, begin, current, end, f, captures, stack);
4385+ return evaluate_recursive(i, begin, current, end, f, captures, stack);
43824386#endif
4387+ }
43834388
43844389}
43854390
@@ -5597,10 +5602,10 @@ struct flat_array {
55975602 if(it == std::end(data))
55985603 return false;
55995604 }
5605+ return false;
56005606 } else {
56015607 return detail::binary_search(std::begin(data), std::end(data), u);
56025608 }
5603- return false;
56045609 }
56055610};
56065611
0 commit comments