@@ -116,12 +116,17 @@ template <typename CharT, typename Iterator, typename EndIterator> constexpr CTR
116
116
}
117
117
118
118
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 {
119
- if constexpr (!std::is_same_v<Iterator, utf8_iterator> && is_random_accessible (typename std::iterator_traits<Iterator>::iterator_category{})) {
120
- bool same = (::std::distance (current, end) >= sizeof ...(String)) && ((String == *(current + Idx)) & ...);
119
+ #if __cpp_char8_t >= 201811
120
+ if constexpr (!std::is_same_v<Iterator, utf8_iterator> && is_random_accessible (typename std::iterator_traits<Iterator>::iterator_category{}) && !std::is_same_v<EndIterator, struct ctre ::zero_terminated_string_end_iterator>) {
121
+ #else
122
+ if constexpr (is_random_accessible (typename std::iterator_traits<Iterator>::iterator_category{}) && !std::is_same_v<EndIterator, struct ctre ::zero_terminated_string_end_iterator>) {
123
+ #endif
124
+ using char_type = decltype (*current);
125
+ bool same = ((size_t )std::distance (current, end) >= sizeof ...(String)) && ((static_cast <char_type>(String) == *(current + Idx)) && ...);
121
126
if (same) {
122
- return {current+= sizeof ...(String), same};
127
+ return { current += sizeof ...(String), same };
123
128
} else {
124
- return {current, same};
129
+ return { current, same };
125
130
}
126
131
} else {
127
132
bool same = (compare_character (String, current, end) && ... && true );
@@ -530,63 +535,63 @@ constexpr CTRE_FORCE_INLINE R evaluate(const Iterator begin, Iterator current, c
530
535
}
531
536
532
537
template <typename T>
533
- constexpr bool is_string (T) {
538
+ constexpr bool is_string (T) noexcept {
534
539
return false ;
535
540
}
536
541
template <auto ... String>
537
- constexpr bool is_string (string<String...>) {
542
+ constexpr bool is_string (string<String...>)noexcept {
538
543
return true ;
539
544
}
540
545
541
546
template <typename T>
542
- constexpr bool is_string_like (T) {
547
+ constexpr bool is_string_like (T) noexcept {
543
548
return false ;
544
549
}
545
550
template <auto ... String>
546
- constexpr bool is_string_like (string<String...>) {
551
+ constexpr bool is_string_like (string<String...>) noexcept {
547
552
return true ;
548
553
}
549
554
template <typename CharacterLike, typename = std::enable_if_t <MatchesCharacter<CharacterLike>::template value<decltype (*std::declval<std::string_view::iterator>())>>>
550
- constexpr bool is_string_like (CharacterLike) {
555
+ constexpr bool is_string_like (CharacterLike) noexcept {
551
556
return true ;
552
557
}
553
558
554
559
template <typename ... Content>
555
- constexpr auto extract_leading_string (ctll::list<Content...>) -> ctll::list<Content...> {
560
+ constexpr auto extract_leading_string (ctll::list<Content...>) noexcept -> ctll::list<Content...> {
556
561
return {};
557
- };
562
+ }
558
563
template <typename ... Content>
559
- constexpr auto extract_leading_string (sequence<Content...>) -> sequence<Content...> {
564
+ constexpr auto extract_leading_string (sequence<Content...>) noexcept -> sequence<Content...> {
560
565
return {};
561
- };
566
+ }
562
567
563
568
// concatenation
564
569
template <auto C, auto ... String, typename ... Content>
565
- constexpr auto extract_leading_string (ctll::list<string<String...>, character<C>, Content...>) {
570
+ constexpr auto extract_leading_string (ctll::list<string<String...>, character<C>, Content...>) noexcept {
566
571
return extract_leading_string (ctll::list<string<String..., C>, Content...>());
567
572
}
568
573
569
574
template <auto ... StringA, auto ... StringB, typename ... Content>
570
- constexpr auto extract_leading_string (ctll::list<string<StringA...>, string<StringB...>, Content...>) {
571
- return extract_leading_string (ctll::list<string<StringA..., StringB>, Content...>());
575
+ constexpr auto extract_leading_string (ctll::list<string<StringA...>, string<StringB...>, Content...>) noexcept {
576
+ return extract_leading_string (ctll::list<string<StringA..., StringB... >, Content...>());
572
577
}
573
578
// move things up out of sequences
574
579
template <typename ... Content, typename ... Tail>
575
- constexpr auto extract_leading_string (ctll::list<sequence<Content...>, Tail...>) {
580
+ constexpr auto extract_leading_string (ctll::list<sequence<Content...>, Tail...>) noexcept {
576
581
return extract_leading_string (ctll::list<Content..., Tail...>());
577
582
}
578
583
579
584
template <typename T, typename ... Content, typename ... Tail>
580
- constexpr auto extract_leading_string (ctll::list<T, sequence<Content...>, Tail...>) {
585
+ constexpr auto extract_leading_string (ctll::list<T, sequence<Content...>, Tail...>) noexcept {
581
586
return extract_leading_string (ctll::list<T, Content..., Tail...>());
582
587
}
583
588
584
589
template <typename ... Content>
585
- constexpr auto make_into_sequence (ctll::list<Content...>) -> sequence<Content...> {
590
+ constexpr auto make_into_sequence (ctll::list<Content...>) noexcept -> sequence<Content...> {
586
591
return {};
587
592
}
588
593
template <typename ... Content>
589
- constexpr auto make_into_sequence (sequence<Content...>) -> sequence<Content...> {
594
+ constexpr auto make_into_sequence (sequence<Content...>) noexcept -> sequence<Content...> {
590
595
return {};
591
596
}
592
597
@@ -642,8 +647,12 @@ template <typename Iterator> struct string_search_result {
642
647
};
643
648
644
649
template <typename Iterator, typename EndIterator, auto ... String>
645
- constexpr CTRE_FORCE_INLINE string_search_result<Iterator> search_for_string (Iterator current, const EndIterator end, string<String...>) {
650
+ constexpr CTRE_FORCE_INLINE string_search_result<Iterator> search_for_string (Iterator current, const EndIterator end, string<String...>) noexcept {
651
+ #if __cpp_char8_t >= 201811
646
652
if constexpr (sizeof ...(String) > 2 && !std::is_same_v<Iterator, utf8_iterator> && is_random_accessible (typename std::iterator_traits<Iterator>::iterator_category{})) {
653
+ #else
654
+ if constexpr (sizeof ...(String) > 2 && is_random_accessible (typename std::iterator_traits<Iterator>::iterator_category{})) {
655
+ #endif
647
656
constexpr std::array<typename ::std::iterator_traits<Iterator>::value_type, sizeof ...(String)> chars{ String... };
648
657
constexpr std::array<ptrdiff_t , sizeof ...(String)> delta_2 = make_delta_2<typename ::std::iterator_traits<Iterator>::value_type>(string<String...>());
649
658
@@ -666,7 +675,7 @@ constexpr CTRE_FORCE_INLINE string_search_result<Iterator> search_for_string(Ite
666
675
}
667
676
668
677
return { current + str_size, current + str_size, false };
669
- } else if (sizeof ...(String)) {
678
+ } else if constexpr (sizeof ...(String)) {
670
679
// fallback to plain string matching
671
680
constexpr std::array<typename ::std::iterator_traits<Iterator>::value_type, sizeof ...(String)> chars{ String... };
672
681
constexpr typename ::std::iterator_traits<Iterator>::value_type first_char = chars.data ()[0 ];
0 commit comments