diff --git a/doc/tables.qbk b/doc/tables.qbk index 211749e4..eabfacf9 100644 --- a/doc/tables.qbk +++ b/doc/tables.qbk @@ -34,19 +34,17 @@ itself be used as a parser; it must be called. In the table below: * `a` is a semantic action; -* `r` is an object whose type models `parsable_range_like`; and +* `r` is an object whose type models `parsable_range`; and * `p`, `p1`, `p2`, ... are parsers. * `escapes` is a _symbols_t_ object, where `T` is `char` or `char32_t`. -[note The definition of `parsable_range_like` is: +[note The definition of `parsable_range` is: -[parsable_range_like_concept] +[parsable_range_concept] -It is intended to be a range-like thing; a null-terminated sequence of -characters is considered range-like, given that a pointer `T *` to a -null-terminated string is isomorphic with `subrange`.] +] [note Some of the parsers in this table consume no input. All parsers consume the input they match unless otherwise stated in the table below.] @@ -371,7 +369,7 @@ Here are all the operator overloaded for parsers. In the tables below: * `a` is a semantic action; -* `r` is an object whose type models `parsable_range_like` (see _concepts_); +* `r` is an object whose type models `parsable_range` (see _concepts_); and * `p`, `p1`, `p2`, ... are parsers. diff --git a/doc/tutorial.qbk b/doc/tutorial.qbk index 7c94f1ec..c2fd45e7 100644 --- a/doc/tutorial.qbk +++ b/doc/tutorial.qbk @@ -1807,8 +1807,7 @@ common: * They each return a value contextually convertible to `bool`. * They each take at least a range to parse and a parser. The "range to parse" - may be an iterator/sentinel pair or an single range-like object. Note that - "range-like" includes null-terminated string pointers. + may be an iterator/sentinel pair or an single range object. * They each require forward iterability of the range to parse. @@ -1823,7 +1822,7 @@ common: the last location within the input that `p` matched. The *whole* input was matched if and only if `first == last` after the call to _p_. -* When you call any of the range-like overloads of _p_, for example `_p_np_(r, +* When you call any of the range overloads of _p_, for example `_p_np_(r, p, _ws_)`, _p_ only indicates success if *all* of `r` was matched by `p`. [note `wchar_t` is an accepted value type for the input. Please note that @@ -1834,7 +1833,7 @@ this is interpreted as UTF-16 on MSVC, and UTF-32 everywhere else.] There are eight overloads of _p_ and _pp_ combined, because there are three either/or options in how you call them. -[heading Iterator/sentinel versus range-like] +[heading Iterator/sentinel versus range] You can call _pp_ with an iterator and sentinel that delimit a range of character values. For example: @@ -1868,32 +1867,11 @@ allows calls like `_p_np_("str", p)` to work naturally. auto result_2 = bp::parse(U"str", p, bp::ws); char const * str_3 = "str"; - auto result_3 = bp::parse(str_3 | boost::parser::as_utf16, p, bp::ws); - -You can also call _p_ with a pointer to a null-terminated string of character -values. _p_ considers pointers to null-terminated strings to be ranges, -since, for any pointer `T *` to a null-terminated string, `T *` is isomorphic -with `subrange`. - - namespace bp = boost::parser; - auto const p = /* some parser ... */; - - char const * str_1 = /* ... */ ; - auto result_1 = bp::parse(str_1, p, bp::ws); - char8_t const * str_2 = /* ... */ ; - auto result_2 = bp::parse(str_2, p, bp::ws); - char16_t const * str_3 = /* ... */ ; - auto result_3 = bp::parse(str_3, p, bp::ws); - char32_t const * str_4 = /* ... */ ; - auto result_4 = bp::parse(str_4, p, bp::ws); - - int const array[] = { 's', 't', 'r', 0 }; - int const * array_ptr = array; - auto result_5 = bp::parse(array_ptr, p, bp::ws); + auto result_3 = bp::parse(bp::null_term(str_3) | bp::as_utf16, p, bp::ws); Since there is no way to indicate that `p` matches the input, but only a -prefix of the input was matched, the range-like (non-iterator/sentinel) -overloads of _p_ indicate failure if the entire input is not matched. +prefix of the input was matched, the range (non-iterator/sentinel) overloads +of _p_ indicate failure if the entire input is not matched. [heading With or without an attribute out-parameter] @@ -3049,10 +3027,9 @@ code paths, as they are written generically. The only difference is that the Unicode code path parses the input as a range of code points, and the non-Unicode path does not. In effect, this means that, in the Unicode code path, when you call `_p_np_(r, p)` for some input range `r` and some parser -`p`, the parse happens as if you called `_p_np_(r | boost::parser::as_utf32, p)` -instead. (Of course, it does not matter if `r` is a null-terminated pointer, -a proper range, or an iterator/sentinel pair; those all work fine with -`boost::parser::as_utf32`.) +`p`, the parse happens as if you called `_p_np_(r | boost::parser::as_utf32, +p)` instead. (Of course, it does not matter if `r` is a proper range, or an +iterator/sentinel pair; those both work fine with `boost::parser::as_utf32`.) Matching "characters" within _Parser_'s parsers is assumed to be a code point match. In the Unicode path there is a code point from the input that is @@ -3187,8 +3164,7 @@ the parser. The other adaptors `as_utf8` and `as_utf16` are also provided for completeness, if you want to use them. They each can transcode any sequence -of character types. A null-terminated string is considered a sequence of -character type. +of character types. [important The `as_utfN` adaptors are optional, so they don't come with `parser.hpp`. To get access to them, `#include diff --git a/include/boost/parser/detail/stl_interfaces/view_adaptor.hpp b/include/boost/parser/detail/stl_interfaces/view_adaptor.hpp index b4a2af22..7a73cdbf 100644 --- a/include/boost/parser/detail/stl_interfaces/view_adaptor.hpp +++ b/include/boost/parser/detail/stl_interfaces/view_adaptor.hpp @@ -58,6 +58,30 @@ namespace boost::parser::detail { namespace stl_interfaces { constexpr bool is_invocable_v = is_detected_v; + // This ensures that captures don't decay from arrays to pointers. + // The decay is fine to do for NTBSs, but not arrays like {'a', 'b'}. + // This is done here since it's too late to see that we were passed an + // array where we need it, much later. Consider a call to replace() + // for instance -- we'd want to know in the replace_impl function that + // we were passed an array, but by then it's too late. We are + // *thoroughly* unlikely to be passed anything but an array of + // characters, so I'm not checking here that the array is not ints or + // whatever before chopping off the null terminator. + template + auto array_to_range(CharT (&arr)[N]) + { + auto const first = std::begin(arr); + auto last = std::end(arr); + if (N && !arr[N - 1]) + --last; + return BOOST_PARSER_SUBRANGE(first, last); + } + template + decltype(auto) array_to_range(T && x) + { + return (T &&)x; + } + template struct bind_back_t { @@ -69,7 +93,8 @@ namespace boost::parser::detail { namespace stl_interfaces { template explicit constexpr bind_back_t(int, F && f, Args &&... args) : - f_((F &&) f), bound_args_((Args &&) args...) + f_((F &&) f), + bound_args_((Args &&) args...) { static_assert(sizeof...(Args) == sizeof...(CapturedArgs), ""); } @@ -125,8 +150,9 @@ namespace boost::parser::detail { namespace stl_interfaces { template constexpr auto bind_back(Func && f, Args &&... args) { - return detail::bind_back_result( - 0, (Func &&) f, (Args &&) args...); + return detail::bind_back_result< + Func, detail::remove_cvref_t()))>...>( + 0, (Func &&) f, detail::array_to_range((Args &&) args)...); } #if BOOST_PARSER_DEFINE_CUSTOM_RANGE_ADAPTOR_CLOSURE || \ diff --git a/include/boost/parser/detail/text/concepts.hpp b/include/boost/parser/detail/text/concepts.hpp index 28ea7a7c..26cbc20a 100644 --- a/include/boost/parser/detail/text/concepts.hpp +++ b/include/boost/parser/detail/text/concepts.hpp @@ -51,10 +51,6 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME utf8_code_unit || utf16_code_unit || utf32_code_unit; - template - concept code_unit_pointer = - std::is_pointer_v && code_unit, F>; - template concept code_unit_range = std::ranges::input_range && code_unit, F>; @@ -66,8 +62,6 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME template concept utf8_iter = code_unit_iter; template - concept utf8_pointer = code_unit_pointer; - template concept utf8_range = code_unit_range; template concept contiguous_utf8_range = contiguous_code_unit_range; @@ -75,8 +69,6 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME template concept utf16_iter = code_unit_iter; template - concept utf16_pointer = code_unit_pointer; - template concept utf16_range = code_unit_range; template concept contiguous_utf16_range = @@ -85,8 +77,6 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME template concept utf32_iter = code_unit_iter; template - concept utf32_pointer = code_unit_pointer; - template concept utf32_range = code_unit_range; template concept contiguous_utf32_range = @@ -102,9 +92,6 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME template concept utf_iter = utf8_iter || utf16_iter || utf32_iter; template - concept utf_pointer = - utf8_pointer || utf16_pointer || utf32_pointer; - template concept utf_range = utf8_range || utf16_range || utf32_range; @@ -182,23 +169,6 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME { t(msg) } -> std::same_as; // clang-format on }; - - template - // clang-format off - concept utf_range_like = - utf_range> || - utf_pointer>; - // clang-format on - - template - concept utf8_range_like = utf8_code_unit> || - utf8_pointer>; - template - concept utf16_range_like = utf16_code_unit> || - utf16_pointer>; - template - concept utf32_range_like = utf32_code_unit> || - utf32_pointer>; //] // Clang 13 defines __cpp_lib_concepts but not std::indirectly copyable. diff --git a/include/boost/parser/detail/text/transcode_algorithm.hpp b/include/boost/parser/detail/text/transcode_algorithm.hpp index e06b0720..a8b869c0 100644 --- a/include/boost/parser/detail/text/transcode_algorithm.hpp +++ b/include/boost/parser/detail/text/transcode_algorithm.hpp @@ -19,34 +19,6 @@ namespace boost::parser::detail { namespace text { - template - struct utf_range_like_iterator - { - using type = decltype(std::declval().begin()); - }; - - template - struct utf_range_like_iterator - { - using type = T *; - }; - - template - struct utf_range_like_iterator - { - using type = T *; - }; - - template - struct utf_range_like_iterator - { - using type = T *; - }; - - template - using utf_range_like_iterator_t = - typename utf_range_like_iterator::type; - /** An alias for `in_out_result` returned by algorithms that perform a transcoding copy. */ template @@ -652,7 +624,7 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME } template - transcode_result, OutIter> + transcode_result, OutIter> transcode_to_utf8(Range && r, OutIter out) { return dtl::transcode_to_8_dispatch::call( @@ -670,7 +642,7 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME } template - transcode_result, OutIter> + transcode_result, OutIter> transcode_to_utf16(Range && r, OutIter out) { return dtl::transcode_to_16_dispatch::call( @@ -688,7 +660,7 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME } template - transcode_result, OutIter> + transcode_result, OutIter> transcode_to_utf32(Range && r, OutIter out) { return dtl::transcode_to_32_dispatch::call( @@ -719,16 +691,12 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME } template O> - requires(utf16_range_like || utf32_range_like) + requires(utf16_range || utf32_range) transcode_result, O> transcode_to_utf8( R && r, O out) { - if constexpr (std::is_pointer_v>) { - return text::transcode_to_utf8(r, null_sentinel, out); - } else { - return text::transcode_to_utf8( - std::ranges::begin(r), std::ranges::end(r), out); - } + return text::transcode_to_utf8( + std::ranges::begin(r), std::ranges::end(r), out); } @@ -750,16 +718,12 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME } template O> - requires(utf8_range_like || utf32_range_like) + requires(utf8_range || utf32_range) transcode_result, O> transcode_to_utf16( R && r, O out) { - if constexpr (std::is_pointer_v>) { - return text::transcode_to_utf16(r, null_sentinel, out); - } else { - return text::transcode_to_utf16( - std::ranges::begin(r), std::ranges::end(r), out); - } + return text::transcode_to_utf16( + std::ranges::begin(r), std::ranges::end(r), out); } @@ -781,16 +745,12 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME } template O> - requires(utf8_range_like || utf16_range_like) + requires(utf8_range || utf16_range) transcode_result, O> transcode_to_utf32( R && r, O out) { - if constexpr (std::is_pointer_v>) { - return text::transcode_to_utf32(r, null_sentinel, out); - } else { - return text::transcode_to_utf32( - std::ranges::begin(r), std::ranges::end(r), out); - } + return text::transcode_to_utf32( + std::ranges::begin(r), std::ranges::end(r), out); } }}} diff --git a/include/boost/parser/detail/text/transcode_view.hpp b/include/boost/parser/detail/text/transcode_view.hpp index 10ae3219..a52a28ad 100644 --- a/include/boost/parser/detail/text/transcode_view.hpp +++ b/include/boost/parser/detail/text/transcode_view.hpp @@ -389,8 +389,7 @@ namespace boost::parser::detail { namespace text { template requires (std::ranges::viewable_range && std::ranges::input_range && - std::convertible_to, format_to_type_t>) || - utf_pointer> + std::convertible_to, format_to_type_t>) #else template #endif @@ -403,9 +402,6 @@ namespace boost::parser::detail { namespace text { #else return 42; // Never gonna happen. #endif - } else if constexpr (std::is_pointer_v) { - return View( - BOOST_PARSER_DETAIL_TEXT_SUBRANGE(r, null_sentinel)); } else { return View(std::forward(r)); } @@ -725,8 +721,7 @@ namespace boost::parser::detail { namespace text { template requires is_utf_view> || (std::ranges::viewable_range && - can_utf_view, View>) || - utf_pointer> + can_utf_view, View>) #else template #endif @@ -743,9 +738,6 @@ namespace boost::parser::detail { namespace text { return View(std::forward(r).base()); } else if constexpr (detail::is_charn_view) { return View(std::forward(r)); - } else if constexpr (std::is_pointer_v) { - return View( - BOOST_PARSER_DETAIL_TEXT_SUBRANGE(r, null_sentinel)); } else { return View(detail::unpack_range(std::forward(r))); } diff --git a/include/boost/parser/parser.hpp b/include/boost/parser/parser.hpp index 0a117bd8..8973abef 100644 --- a/include/boost/parser/parser.hpp +++ b/include/boost/parser/parser.hpp @@ -8430,7 +8430,7 @@ namespace boost { namespace parser { `!detail::derived_from_parser_interface_v`. */ #if BOOST_PARSER_USE_CONCEPTS template< - parsable_range_like R, + parsable_range R, typename Parser, typename GlobalState, typename ErrorHandler, @@ -8443,7 +8443,7 @@ namespace boost { namespace parser { typename ErrorHandler, typename Attr, typename Enable = std::enable_if_t< - detail::is_parsable_range_like_v && + detail::is_parsable_range_v && !detail::derived_from_parser_interface_v< detail::remove_cv_ref_t>>> #endif @@ -8543,7 +8543,7 @@ namespace boost { namespace parser { `!detail::derived_from_parser_interface_v`. */ #if BOOST_PARSER_USE_CONCEPTS template< - parsable_range_like R, + parsable_range R, typename Parser, typename GlobalState, typename ErrorHandler> @@ -8553,7 +8553,7 @@ namespace boost { namespace parser { typename Parser, typename GlobalState, typename ErrorHandler, - typename Enable = std::enable_if_t>> + typename Enable = std::enable_if_t>> #endif auto parse( R const & r, @@ -8672,7 +8672,7 @@ namespace boost { namespace parser { input is non-`char`. */ #if BOOST_PARSER_USE_CONCEPTS template< - parsable_range_like R, + parsable_range R, typename Parser, typename GlobalState, typename ErrorHandler, @@ -8686,7 +8686,7 @@ namespace boost { namespace parser { typename ErrorHandler, typename SkipParser, typename Attr, - typename Enable = std::enable_if_t>> + typename Enable = std::enable_if_t>> #endif bool parse( R const & r, @@ -8787,7 +8787,7 @@ namespace boost { namespace parser { input is non-`char`. */ #if BOOST_PARSER_USE_CONCEPTS template< - parsable_range_like R, + parsable_range R, typename Parser, typename GlobalState, typename ErrorHandler, @@ -8799,7 +8799,7 @@ namespace boost { namespace parser { typename GlobalState, typename ErrorHandler, typename SkipParser, - typename Enable = std::enable_if_t>> + typename Enable = std::enable_if_t>> #endif auto parse( R const & r, @@ -8905,7 +8905,7 @@ namespace boost { namespace parser { input is non-`char`. */ #if BOOST_PARSER_USE_CONCEPTS template< - parsable_range_like R, + parsable_range R, typename Parser, typename GlobalState, typename ErrorHandler, @@ -8917,7 +8917,7 @@ namespace boost { namespace parser { typename GlobalState, typename ErrorHandler, typename Callbacks, - typename Enable = std::enable_if_t>> + typename Enable = std::enable_if_t>> #endif bool callback_parse( R const & r, @@ -9038,7 +9038,7 @@ namespace boost { namespace parser { input is non-`char`. */ #if BOOST_PARSER_USE_CONCEPTS template< - parsable_range_like R, + parsable_range R, typename Parser, typename GlobalState, typename ErrorHandler, @@ -9052,7 +9052,7 @@ namespace boost { namespace parser { typename ErrorHandler, typename SkipParser, typename Callbacks, - typename Enable = std::enable_if_t>> + typename Enable = std::enable_if_t>> #endif bool callback_parse( R const & r, diff --git a/include/boost/parser/parser_fwd.hpp b/include/boost/parser/parser_fwd.hpp index 7e7d95ca..8eb4909b 100644 --- a/include/boost/parser/parser_fwd.hpp +++ b/include/boost/parser/parser_fwd.hpp @@ -58,6 +58,15 @@ namespace boost { namespace parser { template using attribute_t = typename attribute::type; + /** Produces a `subrange` comprising the given pointer and + `null_sentinel`. This should be used to make Null-Terminated Byte + Strings ("NTBSs") compatible with ranges. */ + template + constexpr auto null_term(CharT * ptr) + { + return BOOST_PARSER_SUBRANGE(ptr, detail::text::null_sentinel); + } + namespace detail { template constexpr bool is_optional_v = enable_optional; diff --git a/include/boost/parser/replace.hpp b/include/boost/parser/replace.hpp index eb38f876..e9905ab3 100644 --- a/include/boost/parser/replace.hpp +++ b/include/boost/parser/replace.hpp @@ -522,18 +522,16 @@ namespace boost::parser { #if BOOST_PARSER_USE_CONCEPTS template< - parsable_range_like R, - range_like ReplacementR, + parsable_range R, + std::ranges::range ReplacementR, typename Parser, typename GlobalState, typename ErrorHandler, typename SkipParser> requires // clang-format off - (std::is_pointer_v> || - std::ranges::viewable_range) && - (std::is_pointer_v> || - std::ranges::viewable_range) && + std::ranges::viewable_range && + std::ranges::viewable_range && // clang-format on can_replace_view< to_range_t, @@ -569,17 +567,15 @@ namespace boost::parser { } template< - parsable_range_like R, - range_like ReplacementR, + parsable_range R, + std::ranges::range ReplacementR, typename Parser, typename GlobalState, typename ErrorHandler> requires // clang-format off - (std::is_pointer_v> || - std::ranges::viewable_range) && - (std::is_pointer_v> || - std::ranges::viewable_range) && + std::ranges::viewable_range && + std::ranges::viewable_range && // clang-format on can_replace_view< to_range_t, @@ -619,7 +615,7 @@ namespace boost::parser { typename SkipParser, typename ReplacementR = trace, typename Trace = trace, - typename Enable = std::enable_if_t>> + typename Enable = std::enable_if_t>> [[nodiscard]] constexpr auto operator()( R && r, parser_interface const & @@ -630,7 +626,7 @@ namespace boost::parser { { if constexpr ( is_parser_iface> && - is_range_like> && + is_range> && std::is_same_v) { // (r, parser, skip, replacement, trace) case return impl( @@ -640,7 +636,7 @@ namespace boost::parser { (ReplacementR &&) replacement, trace_mode); } else if constexpr ( - is_range_like> && + is_range> && std::is_same_v, trace> && std::is_same_v) { // (r, parser, replacement, trace) case diff --git a/include/boost/parser/search.hpp b/include/boost/parser/search.hpp index 4b9170fb..c1209d0c 100644 --- a/include/boost/parser/search.hpp +++ b/include/boost/parser/search.hpp @@ -29,7 +29,8 @@ namespace boost::parser { typename R_, bool ToCommonRange = false, text::format OtherRangeFormat = no_format, - bool = std::is_pointer_v> || + bool = std::is_same_v>, + null_sentinel_t> || text::detail::is_bounded_array_v>> struct to_range { @@ -38,20 +39,28 @@ namespace boost::parser { { static_assert(std::is_same_v); using T = remove_cv_ref_t; - if constexpr (std::is_pointer_v) { + if constexpr (std::is_same_v, null_sentinel_t>) { + auto plus_strlen = [](auto * ptr) { + while (*ptr) { + ++ptr; + } + return ptr; + }; + auto const first = r.begin(); if constexpr (OtherRangeFormat == no_format) { - if constexpr (ToCommonRange) - return BOOST_PARSER_SUBRANGE(r, r + std::strlen(r)); - else - return BOOST_PARSER_SUBRANGE(r, null_sentinel_t{}); + if constexpr (ToCommonRange) { + return BOOST_PARSER_SUBRANGE( + first, plus_strlen(first)); + } else { + return (R &&) r; + } } else { if constexpr (ToCommonRange) { return BOOST_PARSER_SUBRANGE( - r, r + std::strlen(r)) | + first, plus_strlen(first)) | as_utf; } else { - return BOOST_PARSER_SUBRANGE(r, null_sentinel_t{}) | - as_utf; + return (R &&) r | as_utf; } } } else if constexpr (text::detail::is_bounded_array_v) { @@ -165,7 +174,7 @@ namespace boost::parser { in C++20 and later if `r` is a non-borrowable rvalue. */ template< #if BOOST_PARSER_USE_CONCEPTS - parsable_range_like R, + parsable_range R, #else typename R, #endif @@ -175,7 +184,7 @@ namespace boost::parser { typename SkipParser #if !BOOST_PARSER_USE_CONCEPTS , - typename Enable = std::enable_if_t> + typename Enable = std::enable_if_t> #endif > auto search( @@ -228,7 +237,7 @@ namespace boost::parser { later if `r` is a non-borrowable rvalue. */ template< #if BOOST_PARSER_USE_CONCEPTS - parsable_range_like R, + parsable_range R, #else typename R, #endif @@ -237,7 +246,7 @@ namespace boost::parser { typename ErrorHandler #if !BOOST_PARSER_USE_CONCEPTS , - typename Enable = std::enable_if_t> + typename Enable = std::enable_if_t> #endif > auto search( @@ -527,13 +536,12 @@ namespace boost::parser { #if BOOST_PARSER_USE_CONCEPTS template< - parsable_range_like R, + parsable_range R, typename Parser, typename GlobalState, typename ErrorHandler, typename SkipParser> requires( - std::is_pointer_v> || std::ranges::viewable_range) && can_search_all_view< to_range_t, @@ -555,12 +563,11 @@ namespace boost::parser { } template< - parsable_range_like R, + parsable_range R, typename Parser, typename GlobalState, typename ErrorHandler> requires( - std::is_pointer_v> || std::ranges::viewable_range) && can_search_all_view< to_range_t, @@ -593,7 +600,7 @@ namespace boost::parser { typename SkipParser = parser_interface>, typename Trace = trace, - typename Enable = std::enable_if_t>> + typename Enable = std::enable_if_t>> [[nodiscard]] constexpr auto operator()( R && r, parser_interface const & diff --git a/include/boost/parser/split.hpp b/include/boost/parser/split.hpp index 7159c711..d47ec906 100644 --- a/include/boost/parser/split.hpp +++ b/include/boost/parser/split.hpp @@ -253,13 +253,12 @@ namespace boost::parser { #if BOOST_PARSER_USE_CONCEPTS template< - parsable_range_like R, + parsable_range R, typename Parser, typename GlobalState, typename ErrorHandler, typename SkipParser> requires( - std::is_pointer_v> || std::ranges::viewable_range) && can_split_view< to_range_t, @@ -281,12 +280,11 @@ namespace boost::parser { } template< - parsable_range_like R, + parsable_range R, typename Parser, typename GlobalState, typename ErrorHandler> requires( - std::is_pointer_v> || std::ranges::viewable_range) && can_split_view< to_range_t, @@ -319,7 +317,7 @@ namespace boost::parser { typename SkipParser = parser_interface>, typename Trace = trace, - typename Enable = std::enable_if_t>> + typename Enable = std::enable_if_t>> [[nodiscard]] constexpr auto operator()( R && r, parser_interface const & diff --git a/include/boost/parser/transform_replace.hpp b/include/boost/parser/transform_replace.hpp index b146c64d..17adb36b 100644 --- a/include/boost/parser/transform_replace.hpp +++ b/include/boost/parser/transform_replace.hpp @@ -640,7 +640,7 @@ namespace boost::parser { #if BOOST_PARSER_USE_CONCEPTS template< - parsable_range_like R, + parsable_range R, std::move_constructible F, typename Parser, typename GlobalState, @@ -648,8 +648,7 @@ namespace boost::parser { typename SkipParser> requires // clang-format off - (std::is_pointer_v> || - std::ranges::viewable_range) && + std::ranges::viewable_range && std::regular_invocable< F &, range_attr_t, Parser>> && @@ -686,15 +685,14 @@ namespace boost::parser { } template< - parsable_range_like R, + parsable_range R, std::move_constructible F, typename Parser, typename GlobalState, typename ErrorHandler> requires // clang-format off - (std::is_pointer_v> || - std::ranges::viewable_range) && + std::ranges::viewable_range && std::regular_invocable< F &, range_attr_t, Parser>> && @@ -736,7 +734,7 @@ namespace boost::parser { typename SkipParser, typename F = trace, typename Trace = trace, - typename Enable = std::enable_if_t>> + typename Enable = std::enable_if_t>> [[nodiscard]] constexpr auto operator()( R && r, parser_interface const & diff --git a/test/compile_attribute.cpp b/test/compile_attribute.cpp index e0c980c2..1e9e0ac9 100644 --- a/test/compile_attribute.cpp +++ b/test/compile_attribute.cpp @@ -62,7 +62,7 @@ void compile_attribute_non_unicode() { constexpr auto parser = char_; - using attr_t = decltype(parse(r, parser)); + using attr_t = decltype(parse(null_term(r), parser)); static_assert(std::is_same_v>); static_assert(std::is_same_v< attribute_t, @@ -70,7 +70,7 @@ void compile_attribute_non_unicode() } { constexpr auto parser = *char_; - using attr_t = decltype(parse(r, parser)); + using attr_t = decltype(parse(null_term(r), parser)); static_assert(std::is_same_v>); static_assert(std::is_same_v< attribute_t, @@ -78,7 +78,7 @@ void compile_attribute_non_unicode() } { constexpr auto parser = string("foo"); - using attr_t = decltype(parse(r, parser)); + using attr_t = decltype(parse(null_term(r), parser)); static_assert(std::is_same_v>); static_assert(std::is_same_v< attribute_t, @@ -86,7 +86,7 @@ void compile_attribute_non_unicode() } { constexpr auto parser = char_ >> string("foo"); - using attr_t = decltype(parse(r, parser)); + using attr_t = decltype(parse(null_term(r), parser)); static_assert(std::is_same_v>); static_assert(std::is_same_v< attribute_t, @@ -94,7 +94,7 @@ void compile_attribute_non_unicode() } { constexpr auto parser = string("foo") >> char_; - using attr_t = decltype(parse(r, parser)); + using attr_t = decltype(parse(null_term(r), parser)); static_assert(std::is_same_v>); static_assert(std::is_same_v< attribute_t, @@ -315,42 +315,42 @@ void compile_attribute_unicode_utf8() { constexpr auto parser = char_; - using attr_t = decltype(parse(r, parser)); + using attr_t = decltype(parse(null_term(r), parser)); static_assert(std::is_same_v>); static_assert(std::is_same_v< - attribute_t, + attribute_t, char32_t>); } { constexpr auto parser = *char_; - using attr_t = decltype(parse(r, parser)); + using attr_t = decltype(parse(null_term(r), parser)); static_assert(std::is_same_v>); static_assert(std::is_same_v< - attribute_t, + attribute_t, std::string>); } { constexpr auto parser = string("foo"); - using attr_t = decltype(parse(r, parser)); + using attr_t = decltype(parse(null_term(r), parser)); static_assert(std::is_same_v>); static_assert(std::is_same_v< - attribute_t, + attribute_t, std::string>); } { constexpr auto parser = char_ >> string("foo"); - using attr_t = decltype(parse(r, parser)); + using attr_t = decltype(parse(null_term(r), parser)); static_assert(std::is_same_v>); static_assert(std::is_same_v< - attribute_t, + attribute_t, std::string>); } { constexpr auto parser = string("foo") >> char_; - using attr_t = decltype(parse(r, parser)); + using attr_t = decltype(parse(null_term(r), parser)); static_assert(std::is_same_v>); static_assert(std::is_same_v< - attribute_t, + attribute_t, std::string>); } } diff --git a/test/no_case.cpp b/test/no_case.cpp index 30f1b60c..3975dcfe 100644 --- a/test/no_case.cpp +++ b/test/no_case.cpp @@ -272,18 +272,18 @@ constexpr auto double_s = u8"sS"; // U+0073 U+0073 { auto const result = - parse(capital_sharp_s | as_utf32, capital_sharp_s_p); + parse(null_term(capital_sharp_s) | as_utf32, capital_sharp_s_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)capital_sharp_s); } { auto const result = - parse(small_sharp_s | as_utf32, capital_sharp_s_p); + parse(null_term(small_sharp_s) | as_utf32, capital_sharp_s_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)small_sharp_s); } { - auto const result = parse(double_s | as_utf32, capital_sharp_s_p); + auto const result = parse(null_term(double_s) | as_utf32, capital_sharp_s_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)double_s); } @@ -302,18 +302,19 @@ constexpr auto double_s = u8"sS"; // U+0073 U+0073 { auto const result = - parse(capital_sharp_s | as_utf32, small_sharp_s_p); + parse(null_term(capital_sharp_s) | as_utf32, small_sharp_s_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)capital_sharp_s); } { auto const result = - parse(small_sharp_s | as_utf32, small_sharp_s_p); + parse(null_term(small_sharp_s) | as_utf32, small_sharp_s_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)small_sharp_s); } { - auto const result = parse(double_s | as_utf32, small_sharp_s_p); + auto const result = + parse(null_term(double_s) | as_utf32, small_sharp_s_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)double_s); } @@ -331,17 +332,20 @@ constexpr auto double_s = u8"sS"; // U+0073 U+0073 constexpr auto double_s_p = no_case[string(double_s)]; { - auto const result = parse(capital_sharp_s | as_utf32, double_s_p); + auto const result = + parse(null_term(capital_sharp_s) | as_utf32, double_s_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)capital_sharp_s); } { - auto const result = parse(small_sharp_s | as_utf32, double_s_p); + auto const result = + parse(null_term(small_sharp_s) | as_utf32, double_s_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)small_sharp_s); } { - auto const result = parse(double_s | as_utf32, double_s_p); + auto const result = + parse(null_term(double_s) | as_utf32, double_s_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)double_s); } @@ -364,13 +368,13 @@ constexpr auto double_s = u8"sS"; // U+0073 U+0073 BOOST_TEST(*result == "s"); } { - BOOST_TEST(!parse(capital_sharp_s | as_utf32, s_p)); + BOOST_TEST(!parse(null_term(capital_sharp_s) | as_utf32, s_p)); } { - BOOST_TEST(!parse(small_sharp_s | as_utf32, s_p)); + BOOST_TEST(!parse(null_term(small_sharp_s) | as_utf32, s_p)); } { - BOOST_TEST(!parse(double_s | as_utf32, s_p)); + BOOST_TEST(!parse(null_term(double_s) | as_utf32, s_p)); } { BOOST_TEST(!parse("x" | as_utf32, s_p)); @@ -482,19 +486,20 @@ constexpr auto double_s = u8"sS"; // U+0073 U+0073 { constexpr auto mixed_sharp_s1_p = no_case[string(mixed_sharp_s1)]; { - auto const result = parse(triple_s | as_utf32, mixed_sharp_s1_p); + auto const result = + parse(null_term(triple_s) | as_utf32, mixed_sharp_s1_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)triple_s); } { auto const result = - parse(mixed_sharp_s1 | as_utf32, mixed_sharp_s1_p); + parse(null_term(mixed_sharp_s1) | as_utf32, mixed_sharp_s1_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)mixed_sharp_s1); } { auto const result = - parse(mixed_sharp_s2 | as_utf32, mixed_sharp_s1_p); + parse(null_term(mixed_sharp_s2) | as_utf32, mixed_sharp_s1_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)mixed_sharp_s2); } @@ -502,19 +507,20 @@ constexpr auto double_s = u8"sS"; // U+0073 U+0073 { constexpr auto mixed_sharp_s2_p = no_case[string(mixed_sharp_s2)]; { - auto const result = parse(triple_s | as_utf32, mixed_sharp_s2_p); + auto const result = + parse(null_term(triple_s) | as_utf32, mixed_sharp_s2_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)triple_s); } { auto const result = - parse(mixed_sharp_s1 | as_utf32, mixed_sharp_s2_p); + parse(null_term(mixed_sharp_s1) | as_utf32, mixed_sharp_s2_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)mixed_sharp_s1); } { auto const result = - parse(mixed_sharp_s2 | as_utf32, mixed_sharp_s2_p); + parse(null_term(mixed_sharp_s2) | as_utf32, mixed_sharp_s2_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)mixed_sharp_s2); } @@ -522,17 +528,20 @@ constexpr auto double_s = u8"sS"; // U+0073 U+0073 { constexpr auto triple_s_p = no_case[string(triple_s)]; { - auto const result = parse(triple_s | as_utf32, triple_s_p); + auto const result = + parse(null_term(triple_s) | as_utf32, triple_s_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)triple_s); } { - auto const result = parse(mixed_sharp_s1 | as_utf32, triple_s_p); + auto const result = + parse(null_term(mixed_sharp_s1) | as_utf32, triple_s_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)mixed_sharp_s1); } { - auto const result = parse(mixed_sharp_s2 | as_utf32, triple_s_p); + auto const result = + parse(null_term(mixed_sharp_s2) | as_utf32, triple_s_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)mixed_sharp_s2); } @@ -541,12 +550,13 @@ constexpr auto double_s = u8"sS"; // U+0073 U+0073 constexpr auto mixed_sharp_s3_p = no_case[string(mixed_sharp_s3)]; { auto const result = - parse(mixed_sharp_s3 | as_utf32, mixed_sharp_s3_p); + parse(null_term(mixed_sharp_s3) | as_utf32, mixed_sharp_s3_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)mixed_sharp_s3); } { - auto const result = parse(quadruple_s | as_utf32, mixed_sharp_s3_p); + auto const result = + parse(null_term(quadruple_s) | as_utf32, mixed_sharp_s3_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)quadruple_s); } @@ -554,12 +564,14 @@ constexpr auto double_s = u8"sS"; // U+0073 U+0073 { constexpr auto quadruple_s_p = no_case[string(quadruple_s)]; { - auto const result = parse(mixed_sharp_s3 | as_utf32, quadruple_s_p); + auto const result = + parse(null_term(mixed_sharp_s3) | as_utf32, quadruple_s_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)mixed_sharp_s3); } { - auto const result = parse(quadruple_s | as_utf32, quadruple_s_p); + auto const result = + parse(null_term(quadruple_s) | as_utf32, quadruple_s_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)quadruple_s); } @@ -567,17 +579,20 @@ constexpr auto double_s = u8"sS"; // U+0073 U+0073 { constexpr auto all_sharp_s1_p = no_case[string(all_sharp_s1)]; { - auto const result = parse(all_sharp_s1 | as_utf32, all_sharp_s1_p); + auto const result = + parse(null_term(all_sharp_s1) | as_utf32, all_sharp_s1_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)all_sharp_s1); } { - auto const result = parse(all_sharp_s2 | as_utf32, all_sharp_s1_p); + auto const result = + parse(null_term(all_sharp_s2) | as_utf32, all_sharp_s1_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)all_sharp_s2); } { - auto const result = parse(all_sharp_s3 | as_utf32, all_sharp_s1_p); + auto const result = + parse(null_term(all_sharp_s3) | as_utf32, all_sharp_s1_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)all_sharp_s3); } @@ -590,17 +605,20 @@ constexpr auto double_s = u8"sS"; // U+0073 U+0073 { constexpr auto all_sharp_s2_p = no_case[string(all_sharp_s1)]; { - auto const result = parse(all_sharp_s1 | as_utf32, all_sharp_s2_p); + auto const result = + parse(null_term(all_sharp_s1) | as_utf32, all_sharp_s2_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)all_sharp_s1); } { - auto const result = parse(all_sharp_s2 | as_utf32, all_sharp_s2_p); + auto const result = + parse(null_term(all_sharp_s2) | as_utf32, all_sharp_s2_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)all_sharp_s2); } { - auto const result = parse(all_sharp_s3 | as_utf32, all_sharp_s2_p); + auto const result = + parse(null_term(all_sharp_s3) | as_utf32, all_sharp_s2_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)all_sharp_s3); } @@ -613,17 +631,20 @@ constexpr auto double_s = u8"sS"; // U+0073 U+0073 { constexpr auto all_sharp_s3_p = no_case[string(all_sharp_s1)]; { - auto const result = parse(all_sharp_s1 | as_utf32, all_sharp_s3_p); + auto const result = + parse(null_term(all_sharp_s1) | as_utf32, all_sharp_s3_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)all_sharp_s1); } { - auto const result = parse(all_sharp_s2 | as_utf32, all_sharp_s3_p); + auto const result = + parse(null_term(all_sharp_s2) | as_utf32, all_sharp_s3_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)all_sharp_s2); } { - auto const result = parse(all_sharp_s3 | as_utf32, all_sharp_s3_p); + auto const result = + parse(null_term(all_sharp_s3) | as_utf32, all_sharp_s3_p); BOOST_TEST(result); BOOST_TEST(*result == (char const *)all_sharp_s3); } diff --git a/test/parser_api.cpp b/test/parser_api.cpp index 6352f983..eea508da 100644 --- a/test/parser_api.cpp +++ b/test/parser_api.cpp @@ -63,10 +63,10 @@ int main() // attr out param, pointer-as-range { char out = 0; - BOOST_TEST(parse(str.c_str(), char_, out)); + BOOST_TEST(parse(null_term(str.c_str()), char_, out)); BOOST_TEST(out == 'a'); out = 0; - BOOST_TEST(!parse(str.c_str(), char_('b'), out)); + BOOST_TEST(!parse(null_term(str.c_str()), char_('b'), out)); BOOST_TEST(out == 0); } @@ -92,9 +92,9 @@ int main() } // returned attr, pointer-as-range { - BOOST_TEST(parse(str.c_str(), char_)); - BOOST_TEST(*parse(str.c_str(), char_) == 'a'); - BOOST_TEST(!parse(str.c_str(), char_('b'))); + BOOST_TEST(parse(null_term(str.c_str()), char_)); + BOOST_TEST(*parse(null_term(str.c_str()), char_) == 'a'); + BOOST_TEST(!parse(null_term(str.c_str()), char_('b'))); } // returned attr, UTF-16 { @@ -139,11 +139,11 @@ int main() // attr out param, using skipper, pointer-as-range { char out = 0; - BOOST_TEST(parse(str.c_str(), char_, ws, out)); + BOOST_TEST(parse(null_term(str.c_str()), char_, ws, out)); BOOST_TEST(out == 'a'); out = 0; auto ws_copy = ws; - BOOST_TEST(!parse(str.c_str(), char_('b'), ws_copy, out)); + BOOST_TEST(!parse(null_term(str.c_str()), char_('b'), ws_copy, out)); BOOST_TEST(out == 0); } @@ -173,10 +173,10 @@ int main() } // returned attr, using skipper, pointer-as-range { - BOOST_TEST(parse(str.c_str(), char_, ws)); - BOOST_TEST(*parse(str.c_str(), char_, ws) == 'a'); + BOOST_TEST(parse(null_term(str.c_str()), char_, ws)); + BOOST_TEST(*parse(null_term(str.c_str()), char_, ws) == 'a'); auto ws_copy = ws; - BOOST_TEST(!parse(str.c_str(), char_('b'), ws_copy)); + BOOST_TEST(!parse(null_term(str.c_str()), char_('b'), ws_copy)); } // callback, iter/sent @@ -203,7 +203,7 @@ int main() { char out = 0; auto callbacks = [&out](auto tag, auto x) { out = x; }; - BOOST_TEST(callback_parse(str.c_str(), callback_char_rule, callbacks)); + BOOST_TEST(callback_parse(null_term(str.c_str()), callback_char_rule, callbacks)); BOOST_TEST(out == 'a'); } @@ -249,7 +249,7 @@ int main() auto callbacks = [&out](auto tag, auto x) { out = x; }; auto ws_copy = ws; BOOST_TEST(callback_parse( - str.c_str(), callback_char_rule, ws_copy, callbacks)); + null_term(str.c_str()), callback_char_rule, ws_copy, callbacks)); BOOST_TEST(out == 'a'); } } @@ -264,49 +264,49 @@ int main() { char const * str = "a"; - BOOST_TEST(parse(str, char_)); - BOOST_TEST(!parse(str, char_('b'))); + BOOST_TEST(parse(null_term(str), char_)); + BOOST_TEST(!parse(null_term(str), char_('b'))); } { char const * str = "a"; char c = '\0'; - BOOST_TEST(parse(str, char_, c)); + BOOST_TEST(parse(null_term(str), char_, c)); BOOST_TEST(c == 'a'); - BOOST_TEST(!parse(str, char_('b'))); + BOOST_TEST(!parse(null_term(str), char_('b'))); } { char const * str = "b"; char c = '\0'; - BOOST_TEST(parse(str, char_("ab"), c)); + BOOST_TEST(parse(null_term(str), char_("ab"), c)); BOOST_TEST(c == 'b'); - BOOST_TEST(!parse(str, char_("cd"))); + BOOST_TEST(!parse(null_term(str), char_("cd"))); } { char const * str = "b"; char c = '\0'; std::string const pattern_1 = "ab"; std::string const pattern_2 = "cd"; - BOOST_TEST(parse(str, char_(pattern_1), c)); + BOOST_TEST(parse(null_term(str), char_(pattern_1), c)); BOOST_TEST(c == 'b'); - BOOST_TEST(!parse(str, char_(pattern_2))); + BOOST_TEST(!parse(null_term(str), char_(pattern_2))); } { char const * str = "b"; char c = '\0'; - BOOST_TEST(parse(str, char_('a', 'b'), c)); + BOOST_TEST(parse(null_term(str), char_('a', 'b'), c)); BOOST_TEST(c == 'b'); - BOOST_TEST(!parse(str, char_('c', 'd'))); + BOOST_TEST(!parse(null_term(str), char_('c', 'd'))); } { char const * str = " "; - BOOST_TEST(parse(str, blank)); - BOOST_TEST(!parse(str, lower)); + BOOST_TEST(parse(null_term(str), blank)); + BOOST_TEST(!parse(null_term(str), lower)); } { char const * str = "ab"; - BOOST_TEST(!parse(str, char_)); - BOOST_TEST(parse(str, parser_1)); - BOOST_TEST(!parse(str, parser_2)); + BOOST_TEST(!parse(null_term(str), char_)); + BOOST_TEST(parse(null_term(str), parser_1)); + BOOST_TEST(!parse(null_term(str), parser_2)); } { std::string str = "ab"; @@ -322,15 +322,15 @@ int main() { char const * str = "ab"; tuple result; - BOOST_TEST(parse(str, parser_1, result)); + BOOST_TEST(parse(null_term(str), parser_1, result)); using namespace boost::parser::literals; BOOST_TEST(get(result, 0_c) == 'b'); BOOST_TEST(get(result, 1_c) == '\0'); } { char const * str = "abc"; - BOOST_TEST(!parse(str, parser_1)); - BOOST_TEST(parse(str, parser_2)); + BOOST_TEST(!parse(null_term(str), parser_1)); + BOOST_TEST(parse(null_term(str), parser_2)); } { std::string str = "abc"; @@ -344,7 +344,7 @@ int main() { char const * str = "abc"; tuple result; - BOOST_TEST(parse(str, parser_2, result)); + BOOST_TEST(parse(null_term(str), parser_2, result)); using namespace boost::parser::literals; BOOST_TEST(get(result, 0_c) == 'c'); BOOST_TEST(get(result, 1_c) == '\0'); @@ -352,33 +352,33 @@ int main() } { char const * str = "a"; - BOOST_TEST(parse(str, parser_3)); - BOOST_TEST(parse(str, parser_4)); + BOOST_TEST(parse(null_term(str), parser_3)); + BOOST_TEST(parse(null_term(str), parser_4)); } { char const * str = "a"; char c = '\0'; - BOOST_TEST(parse(str, parser_3, c)); + BOOST_TEST(parse(null_term(str), parser_3, c)); BOOST_TEST(c == 'a'); } { char const * str = "a"; char c = '\0'; - BOOST_TEST(parse(str, parser_4, c)); + BOOST_TEST(parse(null_term(str), parser_4, c)); BOOST_TEST(c == 'a'); } { char const * str = "z"; - BOOST_TEST(parse(str, parser_3)); - BOOST_TEST(!parse(str, parser_4)); + BOOST_TEST(parse(null_term(str), parser_3)); + BOOST_TEST(!parse(null_term(str), parser_4)); } { char const * str = "a"; - BOOST_TEST(parse(str, parser_5)); + BOOST_TEST(parse(null_term(str), parser_5)); } { char const * str = "z"; - BOOST_TEST(!parse(str, parser_5)); + BOOST_TEST(!parse(null_term(str), parser_5)); } { std::string str = "z"; @@ -389,13 +389,13 @@ int main() { char const * str = "a"; std::optional c; - BOOST_TEST(parse(str, parser_5, c)); + BOOST_TEST(parse(null_term(str), parser_5, c)); BOOST_TEST(c == 'a'); } { char const * str = "z"; std::optional c; - BOOST_TEST(!parse(str, parser_5, c)); + BOOST_TEST(!parse(null_term(str), parser_5, c)); } { std::string str = "z"; @@ -412,49 +412,49 @@ int main() { char const * str = "-42"; short i = 0; - BOOST_TEST(parse(str, short_, i)); + BOOST_TEST(parse(null_term(str), short_, i)); BOOST_TEST(i == -42); } { char const * str = "42"; short i = 0; - BOOST_TEST(parse(str, short_, i)); + BOOST_TEST(parse(null_term(str), short_, i)); BOOST_TEST(i == 42); } { char const * str = "-2000000000"; int i = 0; - BOOST_TEST(parse(str, int_, i)); + BOOST_TEST(parse(null_term(str), int_, i)); BOOST_TEST(i == -2000000000); } { char const * str = "2000000000"; int i = 0; - BOOST_TEST(parse(str, int_, i)); + BOOST_TEST(parse(null_term(str), int_, i)); BOOST_TEST(i == 2000000000); } { char const * str = "-2000000000"; long i = 0; - BOOST_TEST(parse(str, long_, i)); + BOOST_TEST(parse(null_term(str), long_, i)); BOOST_TEST(i == -2000000000); } { char const * str = "2000000000"; long i = 0; - BOOST_TEST(parse(str, long_, i)); + BOOST_TEST(parse(null_term(str), long_, i)); BOOST_TEST(i == 2000000000); } { char const * str = "-4000000000"; long long i = 0; - BOOST_TEST(parse(str, long_long, i)); + BOOST_TEST(parse(null_term(str), long_long, i)); BOOST_TEST(i == -4000000000LL); } { char const * str = "4000000000"; long long i = 0; - BOOST_TEST(parse(str, long_long, i)); + BOOST_TEST(parse(null_term(str), long_long, i)); BOOST_TEST(i == 4000000000LL); } } @@ -464,50 +464,50 @@ int main() { char const * str = "10011"; unsigned int i = 0; - BOOST_TEST(parse(str, bin, i)); + BOOST_TEST(parse(null_term(str), bin, i)); BOOST_TEST(i == 19); } { char const * str = "107"; unsigned int i = 0; - BOOST_TEST(parse(str, oct, i)); + BOOST_TEST(parse(null_term(str), oct, i)); BOOST_TEST(i == 71); } { char const * str = "beef"; unsigned int i = 0; - BOOST_TEST(parse(str, hex, i)); + BOOST_TEST(parse(null_term(str), hex, i)); BOOST_TEST(i == 48879); } { char const * str = "42"; unsigned int i = 0; - BOOST_TEST(parse(str, ushort_, i)); + BOOST_TEST(parse(null_term(str), ushort_, i)); BOOST_TEST(i == 42); } { char const * str = "-42"; unsigned int i = 3; - BOOST_TEST(!parse(str, uint_, i)); + BOOST_TEST(!parse(null_term(str), uint_, i)); BOOST_TEST(i == 0); } { char const * str = "42"; unsigned int i = 0; - BOOST_TEST(parse(str, uint_, i)); + BOOST_TEST(parse(null_term(str), uint_, i)); BOOST_TEST(i == 42); } { char const * str = "42"; unsigned long i = 0; - BOOST_TEST(parse(str, ulong_, i)); + BOOST_TEST(parse(null_term(str), ulong_, i)); BOOST_TEST(i == 42); } { char const * str = "42"; unsigned long long i = 0; - BOOST_TEST(parse(str, ulong_long, i)); + BOOST_TEST(parse(null_term(str), ulong_long, i)); BOOST_TEST(i == 42); } } @@ -517,18 +517,18 @@ int main() { char const * str = ""; bool b = false; - BOOST_TEST(!parse(str, bool_, b)); + BOOST_TEST(!parse(null_term(str), bool_, b)); } { char const * str = "true"; bool b = false; - BOOST_TEST(parse(str, bool_, b)); + BOOST_TEST(parse(null_term(str), bool_, b)); BOOST_TEST(b == true); } { char const * str = "false "; bool b = true; - BOOST_TEST(!parse(str, bool_, b)); + BOOST_TEST(!parse(null_term(str), bool_, b)); } { std::string str = "false "; @@ -540,7 +540,7 @@ int main() } { char const * str = "true "; - auto r = boost::parser::as_utf32(str); + auto r = boost::parser::as_utf32(boost::parser::null_term(str)); bool b = false; auto first = r.begin(); auto const last = r.end(); @@ -549,7 +549,7 @@ int main() } { char const * str = "false"; - auto r = boost::parser::as_utf32(str); + auto r = boost::parser::as_utf32(boost::parser::null_term(str)); bool b = true; auto first = r.begin(); auto const last = r.end(); @@ -565,19 +565,19 @@ int main() { char const * str = ""; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector()); } { char const * str = "a"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({'a'})); } { char const * str = "ba"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({'b', 'a'})); } } @@ -587,19 +587,19 @@ int main() { char const * str = ""; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector()); } { char const * str = "b"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({'b'})); } { char const * str = "bb"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({'b', 'b'})); } } @@ -613,18 +613,18 @@ int main() { char const * str = ""; std::vector chars; - BOOST_TEST(!parse(str, parser, chars)); + BOOST_TEST(!parse(null_term(str), parser, chars)); } { char const * str = "a"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({'a'})); } { char const * str = "ba"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({'b', 'a'})); } } @@ -635,18 +635,18 @@ int main() { char const * str = ""; std::vector chars; - BOOST_TEST(!parse(str, parser, chars)); + BOOST_TEST(!parse(null_term(str), parser, chars)); } { char const * str = "b"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({'b'})); } { char const * str = "bb"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({'b', 'b'})); } } @@ -660,18 +660,18 @@ int main() { char const * str = ""; std::vector chars; - BOOST_TEST(!parse(str, parser, chars)); + BOOST_TEST(!parse(null_term(str), parser, chars)); } { char const * str = "b"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({'b'})); } { char const * str = "bb"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({'b', 'b'})); } } @@ -682,19 +682,19 @@ int main() { char const * str = ""; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector()); } { char const * str = "z"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({'z'})); } { char const * str = "zz"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({'z', 'z'})); } } @@ -705,19 +705,19 @@ int main() { char const * str = ""; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector()); } { char const * str = "z"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({'z'})); } { char const * str = "zz"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({'z', 'z'})); } } @@ -728,19 +728,19 @@ int main() { char const * str = ""; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector()); } { char const * str = "z"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({'z'})); } { char const * str = "zz"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({'z', 'z'})); } } @@ -752,7 +752,7 @@ int main() std::stringstream ss; auto action = [&ss](auto & context) { ss << _attr(context); }; auto parser = *char_('b')[action]; - BOOST_TEST(parse(str, parser)); + BOOST_TEST(parse(null_term(str), parser)); BOOST_TEST(ss.str() == ""); } { @@ -760,7 +760,7 @@ int main() std::stringstream ss; auto action = [&ss](auto & context) { ss << _attr(context); }; auto parser = *char_('b')[action]; - BOOST_TEST(parse(str, parser)); + BOOST_TEST(parse(null_term(str), parser)); BOOST_TEST(ss.str() == "b"); } { @@ -768,8 +768,8 @@ int main() std::stringstream ss; auto action = [&ss](auto & context) { ss << _attr(context); }; auto parser = *char_('b')[action]; - BOOST_TEST(parse(str, parser)); - BOOST_TEST(parse(str, parser)); + BOOST_TEST(parse(null_term(str), parser)); + BOOST_TEST(parse(null_term(str), parser)); BOOST_TEST(ss.str() == "bbbb"); } } @@ -780,7 +780,7 @@ int main() std::stringstream ss; auto action = [&ss](auto & context) { ss << _attr(context); }; auto parser = +char_('b')[action]; - BOOST_TEST(!parse(str, parser)); + BOOST_TEST(!parse(null_term(str), parser)); BOOST_TEST(ss.str() == ""); } { @@ -788,7 +788,7 @@ int main() std::stringstream ss; auto action = [&ss](auto & context) { ss << _attr(context); }; auto parser = +char_('b')[action]; - BOOST_TEST(parse(str, parser)); + BOOST_TEST(parse(null_term(str), parser)); BOOST_TEST(ss.str() == "b"); } { @@ -796,8 +796,8 @@ int main() std::stringstream ss; auto action = [&ss](auto & context) { ss << _attr(context); }; auto parser = +char_('b')[action]; - BOOST_TEST(parse(str, parser)); - BOOST_TEST(parse(str, parser)); + BOOST_TEST(parse(null_term(str), parser)); + BOOST_TEST(parse(null_term(str), parser)); BOOST_TEST(ss.str() == "bbbb"); } } @@ -811,19 +811,19 @@ int main() { char const * str = ""; std::string chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == ""); } { char const * str = "z"; std::string chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == "z"); } { char const * str = "zz"; std::string chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == "zz"); } } @@ -834,19 +834,19 @@ int main() { char const * str = ""; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector()); } { char const * str = "z"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({'z'})); } { char const * str = "zz"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({'z', 'z'})); } } @@ -857,12 +857,12 @@ int main() { char const * str = ""; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector{}); { std::optional> const chars = - parse(str, parser); + parse(null_term(str), parser); BOOST_TEST(chars); BOOST_TEST(chars->empty()); } @@ -903,12 +903,12 @@ int main() { char const * str = "zs"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({"zs"})); { std::optional> const chars = - parse(str, parser); + parse(null_term(str), parser); BOOST_TEST(chars); BOOST_TEST(*chars == std::vector({"zs"})); } @@ -916,12 +916,12 @@ int main() { char const * str = "zszs"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({"zs", "zs"})); { std::optional> const chars = - parse(str, parser); + parse(null_term(str), parser); BOOST_TEST(chars); BOOST_TEST(*chars == std::vector({"zs", "zs"})); } @@ -934,13 +934,13 @@ int main() { char const * str = ""; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector{}); } { char const * str = "z"; std::vector chars; - BOOST_TEST(!parse(str, parser, chars)); + BOOST_TEST(!parse(null_term(str), parser, chars)); } { std::string str = "z"; @@ -955,13 +955,13 @@ int main() { char const * str = "zs"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({"zs"})); } { char const * str = "zszs"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({"zs", "zs"})); } } @@ -974,27 +974,27 @@ int main() { char const * str = ""; - BOOST_TEST(parse(str, parser)); + BOOST_TEST(parse(null_term(str), parser)); } { char const * str = "z"; - BOOST_TEST(parse(str, parser)); + BOOST_TEST(parse(null_term(str), parser)); } { char const * str = "zz"; - BOOST_TEST(parse(str, parser)); + BOOST_TEST(parse(null_term(str), parser)); } { char const * str = ""; - BOOST_TEST(parse(str, parser)); + BOOST_TEST(parse(null_term(str), parser)); } { char const * str = "z"; - BOOST_TEST(parse(str, parser)); + BOOST_TEST(parse(null_term(str), parser)); } { char const * str = "zz"; - BOOST_TEST(parse(str, parser)); + BOOST_TEST(parse(null_term(str), parser)); } } @@ -1003,11 +1003,11 @@ int main() { char const * str = ""; - BOOST_TEST(parse(str, parser)); + BOOST_TEST(parse(null_term(str), parser)); } { char const * str = "z"; - BOOST_TEST(!parse(str, parser)); + BOOST_TEST(!parse(null_term(str), parser)); } { std::string str = "z"; @@ -1017,11 +1017,11 @@ int main() } { char const * str = "zs"; - BOOST_TEST(parse(str, parser)); + BOOST_TEST(parse(null_term(str), parser)); } { char const * str = "zszs"; - BOOST_TEST(parse(str, parser)); + BOOST_TEST(parse(null_term(str), parser)); } } } @@ -1034,48 +1034,48 @@ int main() { char const * str = ""; std::vector chars; - BOOST_TEST(!parse(str, parser, chars)); + BOOST_TEST(!parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector{}); { std::optional> const chars = - parse(str, parser); + parse(null_term(str), parser); BOOST_TEST(!chars); } } { char const * str = "z"; std::vector chars; - BOOST_TEST(!parse(str, parser, chars)); + BOOST_TEST(!parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector{}); { std::optional> const chars = - parse(str, parser); + parse(null_term(str), parser); BOOST_TEST(!chars); } } { char const * str = "zs"; std::vector chars; - BOOST_TEST(!parse(str, parser, chars)); + BOOST_TEST(!parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector{}); { std::optional> const chars = - parse(str, parser); + parse(null_term(str), parser); BOOST_TEST(!chars); } } { char const * str = "zszs"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({"zs", "zs"})); { std::optional> const chars = - parse(str, parser); + parse(null_term(str), parser); BOOST_TEST(chars); BOOST_TEST(*chars == std::vector({"zs", "zs"})); } @@ -1169,60 +1169,60 @@ int main() { char const * str = ""; std::vector chars; - BOOST_TEST(!parse(str, parser, chars)); + BOOST_TEST(!parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector{}); { std::optional> const chars = - parse(str, parser); + parse(null_term(str), parser); BOOST_TEST(!chars); } } { char const * str = "z"; std::vector chars; - BOOST_TEST(!parse(str, parser, chars)); + BOOST_TEST(!parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector{}); { std::optional> const chars = - parse(str, parser); + parse(null_term(str), parser); BOOST_TEST(!chars); } } { char const * str = ","; std::vector chars; - BOOST_TEST(!parse(str, parser, chars)); + BOOST_TEST(!parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector{}); { std::optional> const chars = - parse(str, parser); + parse(null_term(str), parser); BOOST_TEST(!chars); } } { char const * str = ",yay"; std::vector chars; - BOOST_TEST(!parse(str, parser, chars)); + BOOST_TEST(!parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector{}); { std::optional> const chars = - parse(str, parser); + parse(null_term(str), parser); BOOST_TEST(!chars); } } { char const * str = "yay"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({"yay"})); { std::optional> const chars = - parse(str, parser); + parse(null_term(str), parser); BOOST_TEST(chars); BOOST_TEST(*chars == std::vector({"yay"})); } @@ -1296,12 +1296,12 @@ int main() { char const * str = "yay,yay,yay"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({"yay", "yay", "yay"})); { std::optional> const chars = - parse(str, parser); + parse(null_term(str), parser); BOOST_TEST(chars); BOOST_TEST( *chars == std::vector({"yay", "yay", "yay"})); @@ -1314,106 +1314,106 @@ int main() { char const * str = ""; std::vector chars; - BOOST_TEST(!parse(str, parser, char_(' '), chars)); + BOOST_TEST(!parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector{}); } { char const * str = ""; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(!chars); } { char const * str = "z"; std::vector chars; - BOOST_TEST(!parse(str, parser, char_(' '), chars)); + BOOST_TEST(!parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector{}); } { char const * str = "z"; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(!chars); } { char const * str = ","; std::vector chars; - BOOST_TEST(!parse(str, parser, char_(' '), chars)); + BOOST_TEST(!parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector{}); } { char const * str = ","; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(!chars); } { char const * str = " ,yay"; std::vector chars; - BOOST_TEST(!parse(str, parser, char_(' '), chars)); + BOOST_TEST(!parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector{}); } { char const * str = " ,yay"; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(!chars); } { char const * str = ", yay"; std::vector chars; - BOOST_TEST(!parse(str, parser, char_(' '), chars)); + BOOST_TEST(!parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector{}); } { char const * str = ", yay"; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(!chars); } { char const * str = ",yay "; std::vector chars; - BOOST_TEST(!parse(str, parser, char_(' '), chars)); + BOOST_TEST(!parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector{}); } { char const * str = ",yay "; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(!chars); } { char const * str = " , yay "; std::vector chars; - BOOST_TEST(!parse(str, parser, char_(' '), chars)); + BOOST_TEST(!parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector{}); } { char const * str = " , yay "; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(!chars); } { char const * str = "yay"; std::vector chars; - BOOST_TEST(parse(str, parser, char_(' '), chars)); + BOOST_TEST(parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector({"yay"})); } { char const * str = "yay"; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(chars); BOOST_TEST(*chars == std::vector({"yay"})); } { char const * str = "yayyay"; std::vector chars; - BOOST_TEST(!parse(str, parser, char_(' '), chars)); + BOOST_TEST(!parse(null_term(str), parser, char_(' '), chars)); } { std::string str = "yayyay"; @@ -1430,7 +1430,7 @@ int main() { char const * str = "yayyay"; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(!chars); } { @@ -1447,7 +1447,7 @@ int main() { char const * str = "yay,"; std::vector chars; - BOOST_TEST(!parse(str, parser, char_(' '), chars)); + BOOST_TEST(!parse(null_term(str), parser, char_(' '), chars)); } { std::string str = "yay,"; @@ -1464,7 +1464,7 @@ int main() { char const * str = "yay,"; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(!chars); } { @@ -1481,123 +1481,123 @@ int main() { char const * str = "yay,yay,yay"; std::vector chars; - BOOST_TEST(parse(str, parser, char_(' '), chars)); + BOOST_TEST(parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector({"yay", "yay", "yay"})); } { char const * str = "yay,yay,yay"; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(chars); BOOST_TEST(*chars == std::vector({"yay", "yay", "yay"})); } { char const * str = " yay,yay,yay"; std::vector chars; - BOOST_TEST(parse(str, parser, char_(' '), chars)); + BOOST_TEST(parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector({"yay", "yay", "yay"})); } { char const * str = " yay,yay,yay"; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(chars); BOOST_TEST(*chars == std::vector({"yay", "yay", "yay"})); } { char const * str = "yay ,yay,yay"; std::vector chars; - BOOST_TEST(parse(str, parser, char_(' '), chars)); + BOOST_TEST(parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector({"yay", "yay", "yay"})); } { char const * str = "yay ,yay,yay"; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(chars); BOOST_TEST(*chars == std::vector({"yay", "yay", "yay"})); } { char const * str = "yay, yay,yay"; std::vector chars; - BOOST_TEST(parse(str, parser, char_(' '), chars)); + BOOST_TEST(parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector({"yay", "yay", "yay"})); } { char const * str = "yay, yay,yay"; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(chars); BOOST_TEST(*chars == std::vector({"yay", "yay", "yay"})); } { char const * str = "yay,yay ,yay"; std::vector chars; - BOOST_TEST(parse(str, parser, char_(' '), chars)); + BOOST_TEST(parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector({"yay", "yay", "yay"})); } { char const * str = "yay,yay ,yay"; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(chars); BOOST_TEST(*chars == std::vector({"yay", "yay", "yay"})); } { char const * str = "yay,yay, yay"; std::vector chars; - BOOST_TEST(parse(str, parser, char_(' '), chars)); + BOOST_TEST(parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector({"yay", "yay", "yay"})); } { char const * str = "yay,yay, yay"; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(chars); BOOST_TEST(*chars == std::vector({"yay", "yay", "yay"})); } { char const * str = "yay,yay,yay "; std::vector chars; - BOOST_TEST(parse(str, parser, char_(' '), chars)); + BOOST_TEST(parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector({"yay", "yay", "yay"})); } { char const * str = "yay,yay,yay "; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(chars); BOOST_TEST(*chars == std::vector({"yay", "yay", "yay"})); } { char const * str = " yay , yay , yay "; std::vector chars; - BOOST_TEST(parse(str, parser, char_(' '), chars)); + BOOST_TEST(parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector({"yay", "yay", "yay"})); } { char const * str = " yay , yay , yay "; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(chars); BOOST_TEST(*chars == std::vector({"yay", "yay", "yay"})); } { char const * str = "yay, yay, yay"; std::vector chars; - BOOST_TEST(parse(str, parser, char_(' '), chars)); + BOOST_TEST(parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector({"yay", "yay", "yay"})); } { char const * str = "yay, yay, yay"; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(chars); BOOST_TEST(*chars == std::vector({"yay", "yay", "yay"})); } @@ -1630,7 +1630,7 @@ int main() { char const * str = "yay, yay, yay"; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(!chars); } { @@ -1667,7 +1667,7 @@ int main() { char const * str = " yay, yay, yay"; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(!chars); } { @@ -1691,13 +1691,13 @@ int main() { char const * str = "yay, yay, yay"; std::vector chars; - BOOST_TEST(parse(str, parser, char_(' '), chars)); + BOOST_TEST(parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector({"yay", "yay", "yay"})); { char const * str = "yay, yay, yay"; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(chars); BOOST_TEST( *chars == std::vector({"yay", "yay", "yay"})); @@ -1706,13 +1706,13 @@ int main() { char const * str = " yay, yay, yay"; std::vector chars; - BOOST_TEST(parse(str, parser, char_(' '), chars)); + BOOST_TEST(parse(null_term(str), parser, char_(' '), chars)); BOOST_TEST(chars == std::vector({"yay", "yay", "yay"})); { char const * str = " yay, yay, yay"; std::optional> const chars = - parse(str, parser, char_(' ')); + parse(null_term(str), parser, char_(' ')); BOOST_TEST(chars); BOOST_TEST( *chars == std::vector({"yay", "yay", "yay"})); @@ -1729,26 +1729,26 @@ int main() { char const * str = "yay, yay, yay"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({"yay", "yay", "yay"})); } { char const * str = "yay, yay, yay"; std::optional> const chars = - parse(str, parser); + parse(null_term(str), parser); BOOST_TEST(chars); BOOST_TEST(*chars == std::vector({"yay", "yay", "yay"})); } { char const * str = " yay, yay, yay"; std::vector chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == std::vector({"yay", "yay", "yay"})); } { char const * str = " yay, yay, yay"; std::optional> const chars = - parse(str, parser); + parse(null_term(str), parser); BOOST_TEST(chars); BOOST_TEST(*chars == std::vector({"yay", "yay", "yay"})); } @@ -1765,13 +1765,13 @@ int main() { char const * str = "abc"; tuple chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == tup('c', '\0', '\0')); } { char const * str = "abc"; - std::optional const chars = parse(str, parser); + std::optional const chars = parse(null_term(str), parser); BOOST_TEST(chars); BOOST_TEST(*chars == "abc"); } @@ -1779,7 +1779,7 @@ int main() { char const * str = "xyz"; tuple chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == tup('z', '\0', '\0')); } } @@ -1790,13 +1790,13 @@ int main() { char const * str = "abc"; std::string chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == "abc"); } { char const * str = "abc"; - std::optional const chars = parse(str, parser); + std::optional const chars = parse(null_term(str), parser); BOOST_TEST(chars); BOOST_TEST(*chars == "abc"); } @@ -1804,7 +1804,7 @@ int main() { char const * str = "xyz"; std::string chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == "xyz"); } } @@ -1817,13 +1817,13 @@ int main() { char const * str = "abc"; tuple chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); } { char const * str = "xyz"; tuple chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == tup('z', '\0', '\0')); } } @@ -1831,13 +1831,13 @@ int main() { constexpr auto parser = !char_('a'); char const * str = "a"; - BOOST_TEST(!parse(str, parser)); + BOOST_TEST(!parse(null_term(str), parser)); } { constexpr auto parser = &char_('a'); char const * str = "a"; - BOOST_TEST(!parse(str, parser)); + BOOST_TEST(!parse(null_term(str), parser)); } { constexpr auto parser = &char_('a'); @@ -1859,13 +1859,13 @@ int main() { char const * str = "abc"; std::string chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == "abc"); } { char const * str = "abc"; - std::optional const chars = parse(str, parser); + std::optional const chars = parse(null_term(str), parser); BOOST_TEST(chars); BOOST_TEST(*chars == "abc"); } @@ -1873,7 +1873,7 @@ int main() { char const * str = "xyz"; std::string chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == "xyz"); } @@ -1882,14 +1882,14 @@ int main() std::string chars; rethrow_error_handler eh; BOOST_TEST_THROWS( - parse(str, with_error_handler(parser, eh), chars), + parse(null_term(str), with_error_handler(parser, eh), chars), parse_error); } { char const * str = "abz"; std::string chars; - BOOST_TEST(!parse(str, parser, chars)); + BOOST_TEST(!parse(null_term(str), parser, chars)); } // stream_error_handler @@ -1897,21 +1897,21 @@ int main() char const * str = "ab"; std::string chars; stream_error_handler eh; - BOOST_TEST(!parse(str, with_error_handler(parser, eh), chars)); + BOOST_TEST(!parse(null_term(str), with_error_handler(parser, eh), chars)); } { char const * str = "abz"; std::string chars; stream_error_handler eh("simple_parser.cpp"); - BOOST_TEST(!parse(str, with_error_handler(parser, eh), chars)); + BOOST_TEST(!parse(null_term(str), with_error_handler(parser, eh), chars)); } { char const * str = "ab"; std::string chars; stream_error_handler eh("simple_parser.cpp"); - BOOST_TEST(!parse(str, with_error_handler(parser, eh), chars)); + BOOST_TEST(!parse(null_term(str), with_error_handler(parser, eh), chars)); } { @@ -1919,7 +1919,7 @@ int main() std::string chars; std::ostringstream oss; stream_error_handler eh("simple_parser.cpp", oss); - BOOST_TEST(!parse(str, with_error_handler(parser, eh), chars)); + BOOST_TEST(!parse(null_term(str), with_error_handler(parser, eh), chars)); BOOST_TEST( oss.str() == "simple_parser.cpp:1:2: error: Expected char_('c') " @@ -1931,7 +1931,7 @@ int main() std::string chars; std::ostringstream err, warn; stream_error_handler eh("simple_parser.cpp", err, warn); - BOOST_TEST(!parse(str, with_error_handler(parser, eh), chars)); + BOOST_TEST(!parse(null_term(str), with_error_handler(parser, eh), chars)); BOOST_TEST( err.str() == "simple_parser.cpp:1:2: error: Expected char_('c') " @@ -1945,7 +1945,7 @@ int main() char const * str = "ab"; std::string chars; callback_error_handler eh; - BOOST_TEST(!parse(str, with_error_handler(parser, eh), chars)); + BOOST_TEST(!parse(null_term(str), with_error_handler(parser, eh), chars)); } std::string err_str; @@ -1958,7 +1958,7 @@ int main() std::string chars; callback_error_handler eh(err); err_str = ""; - BOOST_TEST(!parse(str, with_error_handler(parser, eh), chars)); + BOOST_TEST(!parse(null_term(str), with_error_handler(parser, eh), chars)); BOOST_TEST( err_str == "1:2: error: Expected char_('c') here:\nabz\n ^\n"); @@ -1969,7 +1969,7 @@ int main() std::string chars; callback_error_handler eh("simple_parser.cpp", err); err_str = ""; - BOOST_TEST(!parse(str, with_error_handler(parser, eh), chars)); + BOOST_TEST(!parse(null_term(str), with_error_handler(parser, eh), chars)); BOOST_TEST( err_str == "simple_parser.cpp:1:2: error: Expected char_('c') " @@ -1982,7 +1982,7 @@ int main() callback_error_handler eh("simple_parser.cpp", err, warn); err_str = ""; warn_str = ""; - BOOST_TEST(!parse(str, with_error_handler(parser, eh), chars)); + BOOST_TEST(!parse(null_term(str), with_error_handler(parser, eh), chars)); BOOST_TEST( err_str == "simple_parser.cpp:1:2: error: Expected char_('c') " @@ -2005,13 +2005,13 @@ int main() { char const * str = "abc"; std::string chars; - BOOST_TEST(parse(str, parser, chars)); + BOOST_TEST(parse(null_term(str), parser, chars)); BOOST_TEST(chars == "abc"); } { char const * str = "abc"; - std::optional const chars = parse(str, parser); + std::optional const chars = parse(null_term(str), parser); BOOST_TEST(chars); BOOST_TEST(*chars == "abc"); } @@ -2019,7 +2019,7 @@ int main() { char const * str = "xyz"; std::string chars; - BOOST_TEST(parse(str, parser, chars, trace::on)); + BOOST_TEST(parse(null_term(str), parser, chars, trace::on)); BOOST_TEST(chars == "xyz"); } } diff --git a/test/replace.cpp b/test/replace.cpp index b08e7487..a2e3308a 100644 --- a/test/replace.cpp +++ b/test/replace.cpp @@ -49,11 +49,6 @@ template using char_str_utf16_replacement = decltype(std::declval() | bp::replace(bp::lit("XYZ"), std::declval() | bp::as_utf16)); static_assert(ill_formed{}); - -template -using utf8_str_char_replacement = - decltype(std::declval() | bp::as_utf8 | bp::replace(bp::lit("XYZ"), std::declval())); -static_assert(ill_formed{}); #endif static_assert( @@ -62,6 +57,17 @@ static_assert( int main() { +// bind_back +{ + auto f = [](auto x) { + static_assert(std::is_same_v< + decltype(x), + BOOST_PARSER_SUBRANGE>); + BOOST_TEST(x.size() == 4u); // stripped off null + }; + bp::detail::stl_interfaces::bind_back(f, "text"); +} + // either_iterator { { @@ -90,26 +96,6 @@ int main() BOOST_TEST(*it == *v_array_curr); } } - { - auto r1 = bp::detail::to_range::call(""); - auto r2 = bp::detail::to_range::call("foo"); - - bp::detail::either_iterator either_r1_begin( - r1.begin()); - bp::detail::either_iterator either_r1_end( - r1.end()); - bp::detail::either_iterator either_r2_begin( - r2.begin()); - bp::detail::either_iterator either_r2_end( - r2.end()); - - BOOST_TEST(either_r1_begin == either_r1_end); - std::string copy; - for (auto it = either_r2_begin; it != either_r2_end; ++it) { - copy.push_back(*it); - } - BOOST_TEST(copy == "foo"); - } } // replace @@ -218,7 +204,8 @@ int main() { char const * str = "XYZXYZaaXYZbaabaXYZXYZ"; char const * replacement = "foo"; - auto r = str | bp::replace(bp::lit("XYZ"), replacement); + auto r = bp::null_term(str) | + bp::replace(bp::lit("XYZ"), bp::null_term(replacement)); int count = 0; std::string_view const strs[] = { "foo", "foo", "aa", "foo", "baaba", "foo", "foo"}; @@ -232,7 +219,8 @@ int main() { char const * str = "XYZXYZaaXYZbaabaXYZXYZ"; char const * replacement = "foo"; - auto const r = str | bp::replace(bp::lit("XYZ"), replacement); + auto const r = bp::null_term(str) | + bp::replace(bp::lit("XYZ"), bp::null_term(replacement)); int count = 0; std::string_view const strs[] = { "foo", "foo", "aa", "foo", "baaba", "foo", "foo"}; @@ -260,7 +248,7 @@ int main() } { char const * str_ = "aaXYZb"; - auto str = str_ | bp::as_utf16; + auto str = bp::null_term(str_) | bp::as_utf16; auto r = bp::replace(str, bp::lit("XYZ"), bp::ws, "foo" | bp::as_utf16); int count = 0; std::string_view const strs[] = {"aa", "foo", "b"}; diff --git a/test/search.cpp b/test/search.cpp index 18e67a0a..e17f61b1 100644 --- a/test/search.cpp +++ b/test/search.cpp @@ -76,7 +76,7 @@ int main() } { char const * str = "XXYZZ"; - auto result = bp::search(str, bp::lit("XYZ"), bp::ws); + auto result = bp::search(bp::null_term(str), bp::lit("XYZ"), bp::ws); BOOST_TEST(result.begin() == str + 1); BOOST_TEST(result.end() == str + 4); } @@ -134,43 +134,43 @@ int main() // pointer { char const * str = ""; - auto result = bp::search(str, bp::lit("XYZ"), bp::ws); + auto result = bp::search(bp::null_term(str), bp::lit("XYZ"), bp::ws); BOOST_TEST(result.begin() == str); BOOST_TEST(result.end() == str); } { char const * str = "not here"; - auto result = bp::search(str, bp::lit("XYZ"), bp::ws); + auto result = bp::search(bp::null_term(str), bp::lit("XYZ"), bp::ws); BOOST_TEST(result.begin() == bp::null_sentinel_t{}); BOOST_TEST(result.end() == bp::null_sentinel_t{}); } { char const * str = "aaXYZb"; - auto result = bp::search(str, bp::lit("XYZ"), bp::ws); + auto result = bp::search(bp::null_term(str), bp::lit("XYZ"), bp::ws); BOOST_TEST(result.begin() == str + 2); BOOST_TEST(result.end() == str + 5); } { char const * str = "XYZab"; - auto result = bp::search(str, bp::lit("XYZ"), bp::ws); + auto result = bp::search(bp::null_term(str), bp::lit("XYZ"), bp::ws); BOOST_TEST(result.begin() == str + 0); BOOST_TEST(result.end() == str + 3); } { char const * str = "gbXYZ"; - auto result = bp::search(str, bp::lit("XYZ"), bp::ws); + auto result = bp::search(bp::null_term(str), bp::lit("XYZ"), bp::ws); BOOST_TEST(result.begin() == str + 2); BOOST_TEST(result.end() == str + 5); } { char const * str = "XYZ"; - auto result = bp::search(str, bp::lit("XYZ"), bp::ws); + auto result = bp::search(bp::null_term(str), bp::lit("XYZ"), bp::ws); BOOST_TEST(result.begin() == str + 0); BOOST_TEST(result.end() == str + 3); } { char const * str = "XXYZZ"; - auto result = bp::search(str, bp::lit("XYZ"), bp::ws); + auto result = bp::search(bp::null_term(str), bp::lit("XYZ"), bp::ws); BOOST_TEST(result.begin() == str + 1); BOOST_TEST(result.end() == str + 4); } @@ -178,49 +178,49 @@ int main() // pointer { char const * str_ = ""; - auto str = str_ | bp::as_utf32; + auto str = bp::null_term(str_) | bp::as_utf32; auto result = bp::search(str, bp::lit("XYZ"), bp::ws); BOOST_TEST(result.begin() == str.begin()); BOOST_TEST(result.end() == str.end()); } { char const * str_ = "not here"; - auto str = str_ | bp::as_utf16; + auto str = bp::null_term(str_) | bp::as_utf16; auto result = bp::search(str, bp::lit("XYZ"), bp::ws); BOOST_TEST(result.begin() == str.end()); BOOST_TEST(result.end() == str.end()); } { char const * str_ = "aaXYZb"; - auto str = str_ | bp::as_utf8; + auto str = bp::null_term(str_) | bp::as_utf8; auto result = bp::search(str, bp::lit("XYZ"), bp::ws); BOOST_TEST(result.begin() == std::next(str.begin(), 2)); BOOST_TEST(result.end() == std::next(str.begin(), 5)); } { char const * str_ = "XYZab"; - auto str = str_ | bp::as_utf32; + auto str = bp::null_term(str_) | bp::as_utf32; auto result = bp::search(str, bp::lit("XYZ"), bp::ws); BOOST_TEST(result.begin() == std::next(str.begin(), 0)); BOOST_TEST(result.end() == std::next(str.begin(), 3)); } { char const * str_ = "gbXYZ"; - auto str = str_ | bp::as_utf16; + auto str = bp::null_term(str_) | bp::as_utf16; auto result = bp::search(str, bp::lit("XYZ"), bp::ws); BOOST_TEST(result.begin() == std::next(str.begin(), 2)); BOOST_TEST(result.end() == std::next(str.begin(), 5)); } { char const * str_ = "XYZ"; - auto str = str_ | bp::as_utf8; + auto str = bp::null_term(str_) | bp::as_utf8; auto result = bp::search(str, bp::lit("XYZ"), bp::ws); BOOST_TEST(result.begin() == std::next(str.begin(), 0)); BOOST_TEST(result.end() == std::next(str.begin(), 3)); } { char const * str_ = "XXYZZ"; - auto str = str_ | bp::as_utf32; + auto str = bp::null_term(str_) | bp::as_utf32; auto result = bp::search(str, bp::lit("XYZ"), bp::ws); BOOST_TEST(result.begin() == std::next(str.begin(), 1)); BOOST_TEST(result.end() == std::next(str.begin(), 4)); @@ -304,7 +304,7 @@ int main() // pointer { char const * str_ = "XYZab"; - auto str = str_ | bp::as_utf32; + auto str = bp::null_term(str_) | bp::as_utf32; auto result = bp::search(str.begin(), str.end(), bp::lit("XYZ"), bp::ws); BOOST_TEST(result.begin() == std::next(str.begin(), 0)); @@ -312,7 +312,7 @@ int main() } { char const * str_ = "gbXYZ"; - auto str = str_ | bp::as_utf16; + auto str = bp::null_term(str_) | bp::as_utf16; auto result = bp::search(str.begin(), str.end(), bp::lit("XYZ"), bp::ws); BOOST_TEST(result.begin() == std::next(str.begin(), 2)); @@ -320,7 +320,7 @@ int main() } { char const * str_ = "XYZ"; - auto str = str_ | bp::as_utf8; + auto str = bp::null_term(str_) | bp::as_utf8; auto result = bp::search(str.begin(), str.end(), bp::lit("XYZ"), bp::ws); BOOST_TEST(result.begin() == std::next(str.begin(), 0)); @@ -373,19 +373,19 @@ int main() // pointer { char const * str = ""; - auto result = bp::search(str, bp::lit("XYZ")); + auto result = bp::search(bp::null_term(str), bp::lit("XYZ")); BOOST_TEST(result.begin() == str); BOOST_TEST(result.end() == str); } { char const * str = "not here"; - auto result = bp::search(str, bp::lit("XYZ")); + auto result = bp::search(bp::null_term(str), bp::lit("XYZ")); BOOST_TEST(result.begin() == bp::null_sentinel_t{}); BOOST_TEST(result.end() == bp::null_sentinel_t{}); } { char const * str = "XXYZZ"; - auto result = bp::search(str, bp::lit("XYZ")); + auto result = bp::search(bp::null_term(str), bp::lit("XYZ")); BOOST_TEST(result.begin() == str + 1); BOOST_TEST(result.end() == str + 4); } @@ -393,21 +393,21 @@ int main() // pointer { char const * str_ = "XYZab"; - auto str = str_ | bp::as_utf32; + auto str = bp::null_term(str_) | bp::as_utf32; auto result = bp::search(str, bp::lit("XYZ")); BOOST_TEST(result.begin() == std::next(str.begin(), 0)); BOOST_TEST(result.end() == std::next(str.begin(), 3)); } { char const * str_ = "gbXYZ"; - auto str = str_ | bp::as_utf16; + auto str = bp::null_term(str_) | bp::as_utf16; auto result = bp::search(str, bp::lit("XYZ")); BOOST_TEST(result.begin() == std::next(str.begin(), 2)); BOOST_TEST(result.end() == std::next(str.begin(), 5)); } { char const * str_ = "XYZ"; - auto str = str_ | bp::as_utf8; + auto str = bp::null_term(str_) | bp::as_utf8; auto result = bp::search(str, bp::lit("XYZ")); BOOST_TEST(result.begin() == std::next(str.begin(), 0)); BOOST_TEST(result.end() == std::next(str.begin(), 3)); @@ -485,21 +485,21 @@ int main() // pointer { char const * str_ = "XYZab"; - auto str = str_ | bp::as_utf32; + auto str = bp::null_term(str_) | bp::as_utf32; auto result = bp::search(str.begin(), str.end(), bp::lit("XYZ")); BOOST_TEST(result.begin() == std::next(str.begin(), 0)); BOOST_TEST(result.end() == std::next(str.begin(), 3)); } { char const * str_ = "gbXYZ"; - auto str = str_ | bp::as_utf16; + auto str = bp::null_term(str_) | bp::as_utf16; auto result = bp::search(str.begin(), str.end(), bp::lit("XYZ")); BOOST_TEST(result.begin() == std::next(str.begin(), 2)); BOOST_TEST(result.end() == std::next(str.begin(), 5)); } { char const * str_ = "XYZ"; - auto str = str_ | bp::as_utf8; + auto str = bp::null_term(str_) | bp::as_utf8; auto result = bp::search(str.begin(), str.end(), bp::lit("XYZ")); BOOST_TEST(result.begin() == std::next(str.begin(), 0)); BOOST_TEST(result.end() == std::next(str.begin(), 3)); @@ -603,7 +603,7 @@ int main() } { char const * str = "XYZXYZaaXYZbaabaXYZXYZ"; - auto r = str | bp::search_all(bp::lit("XYZ")); + auto r = bp::null_term(str) | bp::search_all(bp::lit("XYZ")); int count = 0; int const offsets[] = {0, 3, 3, 6, 8, 11, 16, 19, 19, 22}; for (auto subrange : r) { @@ -615,7 +615,7 @@ int main() } { char const * str = "XYZXYZaaXYZbaabaXYZXYZ"; - auto const r = str | bp::search_all(bp::lit("XYZ")); + auto const r = bp::null_term(str) | bp::search_all(bp::lit("XYZ")); int count = 0; int const offsets[] = {0, 3, 3, 6, 8, 11, 16, 19, 19, 22}; for (auto subrange : r) { @@ -642,7 +642,7 @@ int main() } { char const * str_ = "aaXYZb"; - auto str = str_ | bp::as_utf16; + auto str = bp::null_term(str_) | bp::as_utf16; auto r = bp::search_all(str, bp::lit("XYZ"), bp::ws); int count = 0; int const offsets[] = {2, 5}; diff --git a/test/split.cpp b/test/split.cpp index c888d5f6..2f620db7 100644 --- a/test/split.cpp +++ b/test/split.cpp @@ -126,7 +126,7 @@ int main() } { char const * str = "XYZXYZaaXYZbaabaXYZXYZ"; - auto r = str | bp::split(bp::lit("XYZ")); + auto r = bp::null_term(str) | bp::split(bp::lit("XYZ")); int count = 0; int const offsets[] = {0, 0, 3, 3, 6, 8, 11, 16, 19, 19, 22, 22}; for (auto subrange : r) { @@ -138,7 +138,7 @@ int main() } { char const * str = "XYZXYZaaXYZbaabaXYZXYZ"; - auto const r = str | bp::split(bp::lit("XYZ")); + auto const r = bp::null_term(str) | bp::split(bp::lit("XYZ")); int count = 0; int const offsets[] = {0, 0, 3, 3, 6, 8, 11, 16, 19, 19, 22, 22}; for (auto subrange : r) { @@ -165,7 +165,7 @@ int main() } { char const * str_ = "aaXYZb"; - auto str = str_ | bp::as_utf16; + auto str = bp::null_term(str_) | bp::as_utf16; auto r = bp::split(str, bp::lit("XYZ"), bp::ws); int count = 0; int const offsets[] = {0, 2, 5, 6}; diff --git a/test/transform_replace.cpp b/test/transform_replace.cpp index 726e5005..c13871b4 100644 --- a/test/transform_replace.cpp +++ b/test/transform_replace.cpp @@ -591,7 +591,7 @@ int main() } { char const * str_ = "aa2,3,4b"; - auto str = str_ | bp::as_utf16; + auto str = bp::null_term(str_) | bp::as_utf16; auto r = bp::transform_replace(str, bp::int_ % ',', bp::ws, f_u16str); int count = 0; std::string replace_result;