Skip to content

Commit fb4979d

Browse files
committed
more fixes
1 parent 0766cc0 commit fb4979d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

include/boost/parser/search.hpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,25 @@ namespace boost::parser {
2525
constexpr auto as_utf<text::format::utf32> =
2626
text::detail::as_utf_impl<text::utf32_view, text::format::utf32>{};
2727

28+
template<typename R>
29+
constexpr bool has_special_sentinel_v =
30+
std::is_same_v<sentinel_t<remove_cv_ref_t<R>>, null_sentinel_t> ||
31+
text::detail::is_bounded_array_v<remove_cv_ref_t<R>>;
32+
2833
template<
2934
typename R_,
3035
bool ToCommonRange = false,
31-
text::format OtherRangeFormat = no_format>
36+
text::format OtherRangeFormat = no_format,
37+
bool HasSpecialSentinel = has_special_sentinel_v<R_>>
3238
struct to_range
3339
{
3440
template<typename R>
3541
static constexpr auto call(R && r)
3642
{
3743
static_assert(std::is_same_v<R, R_>);
3844
using T = remove_cv_ref_t<R>;
39-
if constexpr (std::is_same_v<sentinel_t<T>, null_sentinel_t>) {
45+
if constexpr (HasSpecialSentinel &&
46+
std::is_same_v<sentinel_t<T>, null_sentinel_t>) {
4047
auto plus_strlen = [](auto * ptr) {
4148
while (*ptr) {
4249
++ptr;
@@ -60,7 +67,8 @@ namespace boost::parser {
6067
return (R &&) r | as_utf<OtherRangeFormat>;
6168
}
6269
}
63-
} else if constexpr (text::detail::is_bounded_array_v<T>) {
70+
} else if constexpr (HasSpecialSentinel &&
71+
text::detail::is_bounded_array_v<T>) {
6472
auto const first = std::begin(r);
6573
auto last = std::end(r);
6674
constexpr auto n = std::extent_v<T>;

0 commit comments

Comments
 (0)