@@ -37,34 +37,32 @@ template <size_t Limit> constexpr CTRE_FORCE_INLINE bool less_than(size_t i) {
3737 }
3838}
3939
40+ template <typename ResultIterator, typename Pattern> using return_type = decltype (regex_results(std::declval<ResultIterator>(), find_captures(Pattern{})));
41+
4042// calling with pattern prepare stack and triplet of iterators
41- template <typename Iterator, typename EndIterator, typename Pattern>
42- constexpr inline auto match_re (const Iterator begin, const EndIterator end, Pattern pattern) noexcept {
43- using return_type = decltype (regex_results (std::declval<Iterator>(), find_captures (pattern)));
44- return evaluate (begin, begin, end, return_type{}, ctll::list<start_mark, Pattern, assert_end, end_mark, accept>());
43+ template <typename Iterator, typename EndIterator, typename Pattern, typename ResultIterator = Iterator>
44+ constexpr inline auto match_re (const Iterator begin, const EndIterator end, Pattern) noexcept {
45+ return evaluate (begin, begin, end, return_type<ResultIterator, Pattern>{}, ctll::list<start_mark, Pattern, assert_end, end_mark, accept>());
4546}
4647
47- template <typename Iterator, typename EndIterator, typename Pattern>
48- constexpr inline auto starts_with_re (const Iterator begin, const EndIterator end, Pattern pattern) noexcept {
49- using return_type = decltype (regex_results (std::declval<Iterator>(), find_captures (pattern)));
50- return evaluate (begin, begin, end, return_type{}, ctll::list<start_mark, Pattern, end_mark, accept>());
48+ template <typename Iterator, typename EndIterator, typename Pattern, typename ResultIterator = Iterator>
49+ constexpr inline auto starts_with_re (const Iterator begin, const EndIterator end, Pattern) noexcept {
50+ return evaluate (begin, begin, end, return_type<ResultIterator, Pattern>{}, ctll::list<start_mark, Pattern, end_mark, accept>());
5151}
5252
53- template <typename Iterator, typename EndIterator, typename Pattern>
54- constexpr inline auto search_re (const Iterator begin, const EndIterator end, Pattern pattern) noexcept {
55- using return_type = decltype (regex_results (std::declval<Iterator>(), find_captures (pattern)));
56-
53+ template <typename Iterator, typename EndIterator, typename Pattern, typename ResultIterator = Iterator>
54+ constexpr inline auto search_re (const Iterator begin, const EndIterator end, Pattern) noexcept {
5755 constexpr bool fixed = starts_with_anchor (ctll::list<Pattern>{});
5856
5957 auto it = begin;
6058 for (; end != it && !fixed; ++it) {
61- if (auto out = evaluate (begin, it, end, return_type{}, ctll::list<start_mark, Pattern, end_mark, accept>())) {
59+ if (auto out = evaluate (begin, it, end, return_type<ResultIterator, Pattern> {}, ctll::list<start_mark, Pattern, end_mark, accept>())) {
6260 return out;
6361 }
6462 }
6563
6664 // in case the RE is empty or fixed
67- return evaluate (begin, it, end, return_type{}, ctll::list<start_mark, Pattern, end_mark, accept>());
65+ return evaluate (begin, it, end, return_type<ResultIterator, Pattern> {}, ctll::list<start_mark, Pattern, end_mark, accept>());
6866}
6967
7068
@@ -109,7 +107,7 @@ constexpr CTRE_FORCE_INLINE R evaluate(const Iterator, Iterator current, const E
109107
110108template <typename R, typename Iterator, typename EndIterator, typename CharacterLike, typename ... Tail, typename = std::enable_if_t <(MatchesCharacter<CharacterLike>::template value<decltype (*std::declval<Iterator>())>)>>
111109constexpr CTRE_FORCE_INLINE R evaluate (const Iterator begin, Iterator current, const EndIterator end, R captures, ctll::list<CharacterLike, Tail...>) noexcept {
112- if (end == current ) return not_matched;
110+ if (current == end ) return not_matched;
113111 if (!CharacterLike::match_char (*current)) return not_matched;
114112 return evaluate (begin, current+1 , end, captures, ctll::list<Tail...>());
115113}
0 commit comments