Skip to content

Commit ab3cd3f

Browse files
author
Hana Dusíková
committed
fix some unreachable code warning in MSVC
1 parent f6eba26 commit ab3cd3f

File tree

3 files changed

+48
-45
lines changed

3 files changed

+48
-45
lines changed

include/ctre/evaluation.hpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -411,31 +411,32 @@ constexpr CTRE_FORCE_INLINE R evaluate(const Iterator begin, Iterator current, c
411411
}
412412

413413
#ifndef CTRE_DISABLE_GREEDY_OPT
414-
if constexpr (!collides(calculate_first(Content{}...), calculate_first(Tail{}...))) {
414+
else if constexpr (!collides(calculate_first(Content{}...), calculate_first(Tail{}...))) {
415415
return evaluate(begin, current, end, f, captures, ctll::list<possessive_repeat<A,B,Content...>, Tail...>());
416416
}
417417
#endif
418-
419-
// A..B
420-
size_t i{0};
421-
while (less_than<A>(i)) {
422-
auto inner_result = evaluate(begin, current, end, not_empty_match(f), captures, ctll::list<Content..., end_cycle_mark>());
418+
else {
419+
// A..B
420+
size_t i{0};
421+
while (less_than<A>(i)) {
422+
auto inner_result = evaluate(begin, current, end, not_empty_match(f), captures, ctll::list<Content..., end_cycle_mark>());
423423

424-
if (!inner_result) return not_matched;
424+
if (!inner_result) return not_matched;
425425

426-
captures = inner_result.unmatch();
427-
current = inner_result.get_end_position();
426+
captures = inner_result.unmatch();
427+
current = inner_result.get_end_position();
428428

429-
++i;
430-
}
429+
++i;
430+
}
431431

432432
#ifdef CTRE_MSVC_GREEDY_WORKAROUND
433-
R result;
434-
evaluate_recursive(result, i, begin, current, end, f, captures, stack);
435-
return result;
433+
R result;
434+
evaluate_recursive(result, i, begin, current, end, f, captures, stack);
435+
return result;
436436
#else
437-
return evaluate_recursive(i, begin, current, end, f, captures, stack);
437+
return evaluate_recursive(i, begin, current, end, f, captures, stack);
438438
#endif
439+
}
439440

440441
}
441442

single-header/ctre-unicode.hpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4355,31 +4355,32 @@ constexpr CTRE_FORCE_INLINE R evaluate(const Iterator begin, Iterator current, c
43554355
}
43564356

43574357
#ifndef CTRE_DISABLE_GREEDY_OPT
4358-
if constexpr (!collides(calculate_first(Content{}...), calculate_first(Tail{}...))) {
4358+
else if constexpr (!collides(calculate_first(Content{}...), calculate_first(Tail{}...))) {
43594359
return evaluate(begin, current, end, f, captures, ctll::list<possessive_repeat<A,B,Content...>, Tail...>());
43604360
}
43614361
#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>());
4362+
else {
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>());
43674367

4368-
if (!inner_result) return not_matched;
4368+
if (!inner_result) return not_matched;
43694369

4370-
captures = inner_result.unmatch();
4371-
current = inner_result.get_end_position();
4370+
captures = inner_result.unmatch();
4371+
current = inner_result.get_end_position();
43724372

4373-
++i;
4374-
}
4373+
++i;
4374+
}
43754375

43764376
#ifdef CTRE_MSVC_GREEDY_WORKAROUND
4377-
R result;
4378-
evaluate_recursive(result, i, begin, current, end, f, captures, stack);
4379-
return result;
4377+
R result;
4378+
evaluate_recursive(result, i, begin, current, end, f, captures, stack);
4379+
return result;
43804380
#else
4381-
return evaluate_recursive(i, begin, current, end, f, captures, stack);
4381+
return evaluate_recursive(i, begin, current, end, f, captures, stack);
43824382
#endif
4383+
}
43834384

43844385
}
43854386

single-header/ctre.hpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4352,31 +4352,32 @@ constexpr CTRE_FORCE_INLINE R evaluate(const Iterator begin, Iterator current, c
43524352
}
43534353

43544354
#ifndef CTRE_DISABLE_GREEDY_OPT
4355-
if constexpr (!collides(calculate_first(Content{}...), calculate_first(Tail{}...))) {
4355+
else if constexpr (!collides(calculate_first(Content{}...), calculate_first(Tail{}...))) {
43564356
return evaluate(begin, current, end, f, captures, ctll::list<possessive_repeat<A,B,Content...>, Tail...>());
43574357
}
43584358
#endif
4359-
4360-
// A..B
4361-
size_t i{0};
4362-
while (less_than<A>(i)) {
4363-
auto inner_result = evaluate(begin, current, end, not_empty_match(f), captures, ctll::list<Content..., end_cycle_mark>());
4359+
else {
4360+
// A..B
4361+
size_t i{0};
4362+
while (less_than<A>(i)) {
4363+
auto inner_result = evaluate(begin, current, end, not_empty_match(f), captures, ctll::list<Content..., end_cycle_mark>());
43644364

4365-
if (!inner_result) return not_matched;
4365+
if (!inner_result) return not_matched;
43664366

4367-
captures = inner_result.unmatch();
4368-
current = inner_result.get_end_position();
4367+
captures = inner_result.unmatch();
4368+
current = inner_result.get_end_position();
43694369

4370-
++i;
4371-
}
4370+
++i;
4371+
}
43724372

43734373
#ifdef CTRE_MSVC_GREEDY_WORKAROUND
4374-
R result;
4375-
evaluate_recursive(result, i, begin, current, end, f, captures, stack);
4376-
return result;
4374+
R result;
4375+
evaluate_recursive(result, i, begin, current, end, f, captures, stack);
4376+
return result;
43774377
#else
4378-
return evaluate_recursive(i, begin, current, end, f, captures, stack);
4378+
return evaluate_recursive(i, begin, current, end, f, captures, stack);
43794379
#endif
4380+
}
43804381

43814382
}
43824383

0 commit comments

Comments
 (0)