@@ -3001,6 +3001,8 @@ template <size_t Id, typename Name = void> struct captured_content {
3001
3001
#if __cpp_char8_t >= 201811
3002
3002
if constexpr (std::is_same_v<Iterator, utf8_iterator>) {
3003
3003
return static_cast<size_t>(std::distance(_begin.ptr, _end.ptr));
3004
+ } else {
3005
+ return static_cast<size_t>(std::distance(begin(), end()));
3004
3006
}
3005
3007
#endif
3006
3008
return static_cast<size_t>(std::distance(begin(), end()));
@@ -3028,6 +3030,8 @@ template <size_t Id, typename Name = void> struct captured_content {
3028
3030
#if __cpp_char8_t >= 201811
3029
3031
if constexpr (std::is_same_v<Iterator, utf8_iterator>) {
3030
3032
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());
3031
3035
}
3032
3036
#endif
3033
3037
return std::basic_string<char_type>(begin(), end());
@@ -4240,46 +4244,46 @@ constexpr CTRE_FORCE_INLINE R evaluate(const Iterator begin, Iterator current, c
4240
4244
4241
4245
if constexpr (B != 0 && A > B) {
4242
4246
return not_matched;
4243
- }
4244
-
4245
- const Iterator backup_current = current;
4247
+ } else {
4248
+ const Iterator backup_current = current;
4246
4249
4247
- size_t i{0};
4250
+ size_t i{0};
4248
4251
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>());
4251
4254
4252
- if (!outer_result) return not_matched;
4255
+ if (!outer_result) return not_matched;
4253
4256
4254
- captures = outer_result.unmatch();
4255
- current = outer_result.get_end_position();
4257
+ captures = outer_result.unmatch();
4258
+ current = outer_result.get_end_position();
4256
4259
4257
- ++i;
4258
- }
4260
+ ++i;
4261
+ }
4259
4262
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
+ }
4263
4266
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>());
4266
4269
4267
- if (!inner_result) return not_matched;
4270
+ if (!inner_result) return not_matched;
4268
4271
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...>());
4270
4273
4271
- if (outer_result) {
4272
- return outer_result;
4273
- }
4274
+ if (outer_result) {
4275
+ return outer_result;
4276
+ }
4274
4277
4275
- captures = inner_result.unmatch();
4276
- current = inner_result.get_end_position();
4278
+ captures = inner_result.unmatch();
4279
+ current = inner_result.get_end_position();
4277
4280
4278
- ++i;
4279
- }
4281
+ ++i;
4282
+ }
4280
4283
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
+ }
4283
4287
}
4284
4288
4285
4289
// possessive repeat
@@ -4288,24 +4292,24 @@ constexpr CTRE_FORCE_INLINE R evaluate(const Iterator begin, Iterator current, c
4288
4292
4289
4293
if constexpr ((B != 0) && (A > B)) {
4290
4294
return not_matched;
4291
- }
4292
-
4293
- const auto backup_current = current;
4295
+ } else {
4296
+ const auto backup_current = current;
4294
4297
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>());
4298
4301
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
+ }
4303
4306
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
+ }
4307
4310
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
+ }
4309
4313
}
4310
4314
4311
4315
// (gready) repeat
@@ -5598,10 +5602,10 @@ struct flat_array {
5598
5602
if(it == std::end(data))
5599
5603
return false;
5600
5604
}
5605
+ return false;
5601
5606
} else {
5602
5607
return detail::binary_search(std::begin(data), std::end(data), u);
5603
5608
}
5604
- return false;
5605
5609
}
5606
5610
};
5607
5611
0 commit comments