From 884ce6abb5a3bfeec6390e6420dc9042e1e6617d Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Wed, 10 Dec 2025 16:29:10 +0100 Subject: [PATCH 1/8] pass end iterator by const-ref --- include/boost/parser/parser.hpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/include/boost/parser/parser.hpp b/include/boost/parser/parser.hpp index 1c5585f3..d332e2ae 100644 --- a/include/boost/parser/parser.hpp +++ b/include/boost/parser/parser.hpp @@ -2425,7 +2425,7 @@ namespace boost { namespace parser { typename ErrorHandler> bool parse_impl( Iter & first, - Sentinel last, + Sentinel const & last, Parser const & parser, ErrorHandler const & error_handler, Attr & attr) @@ -2478,7 +2478,7 @@ namespace boost { namespace parser { typename ErrorHandler> auto parse_impl( Iter & first, - Sentinel last, + Sentinel const & last, Parser const & parser, ErrorHandler const & error_handler) { @@ -2534,7 +2534,7 @@ namespace boost { namespace parser { typename Callbacks> bool callback_parse_impl( Iter & first, - Sentinel last, + Sentinel const & last, Parser const & parser, ErrorHandler const & error_handler, Callbacks const & callbacks) @@ -2589,7 +2589,7 @@ namespace boost { namespace parser { typename ErrorHandler> bool skip_parse_impl( Iter & first, - Sentinel last, + Sentinel const & last, Parser const & parser, SkipParser const & skip, ErrorHandler const & error_handler, @@ -2639,7 +2639,7 @@ namespace boost { namespace parser { typename ErrorHandler> auto skip_parse_impl( Iter & first, - Sentinel last, + Sentinel const & last, Parser const & parser, SkipParser const & skip, ErrorHandler const & error_handler) @@ -2694,7 +2694,7 @@ namespace boost { namespace parser { typename Callbacks> bool callback_skip_parse_impl( Iter & first, - Sentinel last, + Sentinel const & last, Parser const & parser, SkipParser const & skip, ErrorHandler const & error_handler, @@ -2844,7 +2844,7 @@ namespace boost { namespace parser { T if_full_parse( I initial_first, I & first, - S last, + S const & last, ErrorHandler const & error_handler, T retval) { @@ -9155,7 +9155,7 @@ namespace boost { namespace parser { #endif bool prefix_parse( I & first, - S last, + S const & last, parser_interface const & parser, Attr & attr, trace trace_mode = trace::off) @@ -9294,7 +9294,7 @@ namespace boost { namespace parser { #endif auto prefix_parse( I & first, - S last, + S const & last, parser_interface const & parser, trace trace_mode = trace::off) { @@ -9405,7 +9405,7 @@ namespace boost { namespace parser { #endif bool prefix_parse( I & first, - S last, + S const & last, parser_interface const & parser, parser_interface const & skip, Attr & attr, @@ -9547,7 +9547,7 @@ namespace boost { namespace parser { #endif auto prefix_parse( I & first, - S last, + S const & last, parser_interface const & parser, parser_interface const & skip, trace trace_mode = trace::off) @@ -9664,7 +9664,7 @@ namespace boost { namespace parser { #endif bool callback_prefix_parse( I & first, - S last, + S const & last, parser_interface const & parser, Callbacks const & callbacks, trace trace_mode = trace::off) @@ -9790,7 +9790,7 @@ namespace boost { namespace parser { #endif bool callback_prefix_parse( I & first, - S last, + S const & last, parser_interface const & parser, parser_interface const & skip, Callbacks const & callbacks, From cf92ba1f79e394529823886be195049dafa3baee Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Wed, 10 Dec 2025 16:49:56 +0100 Subject: [PATCH 2/8] pass end iterator by const-ref --- include/boost/parser/parser.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/parser/parser.hpp b/include/boost/parser/parser.hpp index d332e2ae..41ddac73 100644 --- a/include/boost/parser/parser.hpp +++ b/include/boost/parser/parser.hpp @@ -456,7 +456,7 @@ namespace boost { namespace parser { static constexpr bool use_callbacks = UseCallbacks; I first_; - S last_; + S const & last_; bool * pass_ = nullptr; int * trace_indent_ = nullptr; symbol_table_tries_t * symbol_table_tries_ = nullptr; @@ -525,7 +525,7 @@ namespace boost { namespace parser { std::bool_constant, std::bool_constant, I & first, - S last, + S const & last, bool & success, int & indent, ErrorHandler const & error_handler, @@ -548,7 +548,7 @@ namespace boost { namespace parser { std::bool_constant, std::bool_constant, I & first, - S last, + S const & last, bool & success, int & indent, ErrorHandler const & error_handler, @@ -566,7 +566,7 @@ namespace boost { namespace parser { std::bool_constant, std::bool_constant, I & first, - S last, + S const & last, bool & success, int & indent, ErrorHandler const & error_handler, From e65b31fa0df44a35c25c6f31caf47c63f5441126 Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Wed, 10 Dec 2025 17:07:14 +0100 Subject: [PATCH 3/8] pass end iterator by const-ref --- include/boost/parser/parser.hpp | 50 ++++++++++++++--------------- include/boost/parser/parser_fwd.hpp | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/include/boost/parser/parser.hpp b/include/boost/parser/parser.hpp index 41ddac73..6e026806 100644 --- a/include/boost/parser/parser.hpp +++ b/include/boost/parser/parser.hpp @@ -852,7 +852,7 @@ namespace boost { namespace parser { typename ErrorHandler> auto make_context( Iter first, - Sentinel last, + Sentinel const & last, bool & success, int & indent, ErrorHandler const & error_handler, @@ -882,7 +882,7 @@ namespace boost { namespace parser { typename ErrorHandler> auto make_context( Iter first, - Sentinel last, + Sentinel const & last, bool & success, int & indent, ErrorHandler const & error_handler, @@ -910,7 +910,7 @@ namespace boost { namespace parser { typename GlobalState> auto make_context( Iter first, - Sentinel last, + Sentinel const & last, bool & success, int & indent, ErrorHandler const & error_handler, @@ -941,7 +941,7 @@ namespace boost { namespace parser { typename Callbacks> auto make_context( Iter first, - Sentinel last, + Sentinel const & last, bool & success, int & indent, ErrorHandler const & error_handler, @@ -975,7 +975,7 @@ namespace boost { namespace parser { typename GlobalState> auto make_context( Iter first, - Sentinel last, + Sentinel const & last, bool & success, int & indent, ErrorHandler const & error_handler, @@ -1520,7 +1520,7 @@ namespace boost { namespace parser { inline void append(nope &, nope &&, bool) {} template - void append(Container & c, Iter first, Sentinel last, bool gen_attrs) + void append(Container & c, Iter first, Sentinel const & last, bool gen_attrs) { if (!gen_attrs) return; @@ -1539,7 +1539,7 @@ namespace boost { namespace parser { void append( std::optional & c, Iter first, - Sentinel last, + Sentinel const & last, bool gen_attrs) { if (!gen_attrs) @@ -1550,7 +1550,7 @@ namespace boost { namespace parser { } template - void append(nope &, Iter first, Sentinel last, bool gen_attrs) + void append(nope &, Iter first, Sentinel const & last, bool gen_attrs) {} constexpr inline flags default_flags() @@ -1639,12 +1639,12 @@ namespace boost { namespace parser { template void - skip(Iter & first, Sentinel last, null_parser const & skip_, flags f) + skip(Iter & first, Sentinel const & last, null_parser const & skip_, flags f) {} template void - skip(Iter & first, Sentinel last, SkipParser const & skip_, flags f) + skip(Iter & first, Sentinel const & last, SkipParser const & skip_, flags f) { if (!detail::use_skip(f)) return; @@ -1953,7 +1953,7 @@ namespace boost { namespace parser { }; template - constexpr auto make_char_range(Iter first, Sentinel last) + constexpr auto make_char_range(Iter first, Sentinel const & last) { return char_range{ BOOST_PARSER_SUBRANGE{first, last}}; @@ -2279,7 +2279,7 @@ namespace boost { namespace parser { void apply_parser( Parser const & parser, Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, flags flags, @@ -3425,7 +3425,7 @@ namespace boost { namespace parser { } Iter & first_; - Sentinel last_; + Sentinel const & last_; Context const & context_; SkipParser const & skip_; detail::flags flags_; @@ -3441,7 +3441,7 @@ namespace boost { namespace parser { typename SkipParser> auto call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -3506,7 +3506,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -3609,7 +3609,7 @@ namespace boost { namespace parser { } Iter & first_; - Sentinel last_; + Sentinel const & last_; Context const & context_; SkipParser const & skip_; detail::flags flags_; @@ -3625,7 +3625,7 @@ namespace boost { namespace parser { typename SkipParser> auto call( Iter & first_, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -3670,7 +3670,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first_, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -4229,7 +4229,7 @@ namespace boost { namespace parser { typename SkipParser> auto make_temp_result( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -4298,7 +4298,7 @@ namespace boost { namespace parser { typename SkipParser> auto call( Iter & first_, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -4358,7 +4358,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first_, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -4476,7 +4476,7 @@ namespace boost { namespace parser { typename Merged> void call_impl( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -4493,7 +4493,7 @@ namespace boost { namespace parser { ""); auto use_parser = [&first, - last, + &last, &context, &skip, flags_ = flags, @@ -9964,7 +9964,7 @@ namespace boost { namespace parser { using context = decltype(detail::make_context( std::declval(), - std::declval(), + std::declval(), std::declval(), std::declval(), std::declval(), @@ -9973,7 +9973,7 @@ namespace boost { namespace parser { std::declval())); using type = decltype(std::declval()( std::declval(), - std::declval(), + std::declval(), std::declval(), SkipParser{}, detail::flags::gen_attrs, diff --git a/include/boost/parser/parser_fwd.hpp b/include/boost/parser/parser_fwd.hpp index 44565e88..b475cce3 100644 --- a/include/boost/parser/parser_fwd.hpp +++ b/include/boost/parser/parser_fwd.hpp @@ -111,7 +111,7 @@ namespace boost { namespace parser { typename ErrorHandler> inline auto make_context( Iter first, - Sentinel last, + Sentinel const & last, bool & success, int & indent, ErrorHandler const & error_handler, From 4e65d97d787f2b7f88f23b3446da51bf859b5b44 Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Wed, 10 Dec 2025 17:22:33 +0100 Subject: [PATCH 4/8] pass end iterator by const-ref --- include/boost/parser/parser.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/parser/parser.hpp b/include/boost/parser/parser.hpp index 6e026806..fb525a02 100644 --- a/include/boost/parser/parser.hpp +++ b/include/boost/parser/parser.hpp @@ -3152,7 +3152,7 @@ namespace boost { namespace parser { typename SkipParser> auto call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -3173,7 +3173,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -3316,7 +3316,7 @@ namespace boost { namespace parser { typename SkipParser> auto call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -3339,7 +3339,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, From 256b07359e837ed3af988b384a1e4395fb9c51a8 Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Wed, 10 Dec 2025 17:26:47 +0100 Subject: [PATCH 5/8] pass end iterator by const-ref --- include/boost/parser/parser.hpp | 132 ++++++++++++++++---------------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/include/boost/parser/parser.hpp b/include/boost/parser/parser.hpp index fb525a02..3e8e55c3 100644 --- a/include/boost/parser/parser.hpp +++ b/include/boost/parser/parser.hpp @@ -1611,7 +1611,7 @@ namespace boost { namespace parser { typename SkipParser> nope operator()( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, flags flags, @@ -1628,7 +1628,7 @@ namespace boost { namespace parser { typename Attribute> void operator()( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, flags flags, @@ -2312,7 +2312,7 @@ namespace boost { namespace parser { void apply_parser( Parser const & parser, Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, flags flags, @@ -2334,7 +2334,7 @@ namespace boost { namespace parser { void apply_parser( Parser const & parser, Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, flags flags, @@ -2356,7 +2356,7 @@ namespace boost { namespace parser { void apply_parser( Parser const & parser, Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, flags flags, @@ -2371,7 +2371,7 @@ namespace boost { namespace parser { // API implementations template - auto has_attribute(Iter first, Sentinel last, Parser parser); + auto has_attribute(Iter first, Sentinel const & last, Parser parser); template struct scoped_base_assign @@ -3775,7 +3775,7 @@ namespace boost { namespace parser { int... Is> void call_impl( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -3871,7 +3871,7 @@ namespace boost { namespace parser { { dummy_use_parser_t( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -3895,7 +3895,7 @@ namespace boost { namespace parser { success_); } Iter & first_; - Sentinel last_; + Sentinel const & last_; Context const & context_; SkipParser const & skip_; detail::flags flags_; @@ -4695,7 +4695,7 @@ namespace boost { namespace parser { typename SkipParser> detail::nope call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -4714,7 +4714,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -4783,7 +4783,7 @@ namespace boost { namespace parser { typename SkipParser> auto call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -4809,7 +4809,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -4841,7 +4841,7 @@ namespace boost { namespace parser { typename SkipParser> detail::nope call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -4870,7 +4870,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -4904,7 +4904,7 @@ namespace boost { namespace parser { typename SkipParser> BOOST_PARSER_SUBRANGE call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -4923,7 +4923,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -4962,7 +4962,7 @@ namespace boost { namespace parser { typename SkipParser> auto call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -4990,7 +4990,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -5047,7 +5047,7 @@ namespace boost { namespace parser { typename SkipParser> auto call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -5068,7 +5068,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -5103,7 +5103,7 @@ namespace boost { namespace parser { typename SkipParser> auto call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context_, SkipParser const & skip, detail::flags flags, @@ -5127,7 +5127,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context_, SkipParser const & skip, detail::flags flags, @@ -5158,7 +5158,7 @@ namespace boost { namespace parser { typename SkipParser_> auto call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser_ const & skip, detail::flags flags, @@ -5179,7 +5179,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser_ const & skip, detail::flags flags, @@ -5226,7 +5226,7 @@ namespace boost { namespace parser { typename SkipParser> detail::nope call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -5245,7 +5245,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -5395,7 +5395,7 @@ namespace boost { namespace parser { typename SkipParser> T call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -5414,7 +5414,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -5480,7 +5480,7 @@ namespace boost { namespace parser { attr_type> call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -5581,7 +5581,7 @@ namespace boost { namespace parser { typename Attribute_> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -5991,7 +5991,7 @@ namespace boost { namespace parser { typename SkipParserType> auto operator()( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParserType const & skip, detail::flags flags, @@ -6010,7 +6010,7 @@ namespace boost { namespace parser { typename Attribute> void operator()( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParserType const & skip, detail::flags flags, @@ -6324,7 +6324,7 @@ namespace boost { namespace parser { decltype(rule_name_)::parser_type::attr_type parse_rule( \ decltype(rule_name_)::parser_type::tag_type *, \ Iter & first, \ - Sentinel last, \ + Sentinel const & last, \ Context const & context, \ SkipParser const & skip, \ boost::parser::detail::flags flags, \ @@ -6360,7 +6360,7 @@ namespace boost { namespace parser { void parse_rule( \ decltype(rule_name_)::parser_type::tag_type *, \ Iter & first, \ - Sentinel last, \ + Sentinel const & last, \ Context const & context, \ SkipParser const & skip, \ boost::parser::detail::flags flags, \ @@ -6816,7 +6816,7 @@ namespace boost { namespace parser { typename SkipParser> detail::nope call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -6845,7 +6845,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -6899,7 +6899,7 @@ namespace boost { namespace parser { typename SkipParser> detail::nope call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -6922,7 +6922,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -6955,7 +6955,7 @@ namespace boost { namespace parser { typename SkipParser> auto call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const &, detail::flags flags, @@ -6976,7 +6976,7 @@ namespace boost { namespace parser { typename Attribute_> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -7025,7 +7025,7 @@ namespace boost { namespace parser { typename SkipParser> auto call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -7044,7 +7044,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -7192,7 +7192,7 @@ namespace boost { namespace parser { typename SkipParser> auto call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -7211,7 +7211,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -7345,7 +7345,7 @@ namespace boost { namespace parser { typename SkipParser> auto call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -7364,7 +7364,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -7427,7 +7427,7 @@ namespace boost { namespace parser { typename SkipParser> auto call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -7446,7 +7446,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -7551,7 +7551,7 @@ namespace boost { namespace parser { typename SkipParser> std::string call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -7570,7 +7570,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -7717,7 +7717,7 @@ namespace boost { namespace parser { typename SkipParser> std::string call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -7736,7 +7736,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -8040,7 +8040,7 @@ namespace boost { namespace parser { typename SkipParser> detail::nope call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -8059,7 +8059,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -8209,7 +8209,7 @@ namespace boost { namespace parser { typename SkipParser> bool call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -8228,7 +8228,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -8300,7 +8300,7 @@ namespace boost { namespace parser { typename SkipParser> T call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -8319,7 +8319,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -8443,7 +8443,7 @@ namespace boost { namespace parser { typename SkipParser> T call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -8462,7 +8462,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -8560,7 +8560,7 @@ namespace boost { namespace parser { typename SkipParser> T call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -8579,7 +8579,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -8668,7 +8668,7 @@ namespace boost { namespace parser { typename SkipParser> auto call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -8698,7 +8698,7 @@ namespace boost { namespace parser { typename Attribute> void call( Iter & first, - Sentinel last, + Sentinel const & last, Context const & context, SkipParser const & skip, detail::flags flags, @@ -9981,7 +9981,7 @@ namespace boost { namespace parser { }; template - auto has_attribute(Iter first, Sentinel last, Parser parser) + auto has_attribute(Iter first, Sentinel const & last, Parser parser) { using attr_t = typename attribute_impl< BOOST_PARSER_SUBRANGE, From 678ea490ada26470f52d6c970abdc99dc3970487 Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Wed, 10 Dec 2025 17:34:57 +0100 Subject: [PATCH 6/8] pass end iterator by const-ref --- .../boost/parser/detail/text/algorithm.hpp | 33 ++++++++++--------- .../detail/text/transcode_algorithm.hpp | 26 +++++++-------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/include/boost/parser/detail/text/algorithm.hpp b/include/boost/parser/detail/text/algorithm.hpp index 9f22affb..09660a52 100644 --- a/include/boost/parser/detail/text/algorithm.hpp +++ b/include/boost/parser/detail/text/algorithm.hpp @@ -21,13 +21,13 @@ namespace boost::parser::detail { namespace text { namespace detail { template - std::ptrdiff_t distance(Iter first, Iter last, non_sentinel_tag) + std::ptrdiff_t distance(Iter first, Iter const & last, non_sentinel_tag) { return std::distance(first, last); } template - std::ptrdiff_t distance(Iter first, Sentinel last, sentinel_tag) + std::ptrdiff_t distance(Iter first, Sentinel const & last, sentinel_tag) { std::ptrdiff_t retval = 0; while (first != last) { @@ -41,7 +41,7 @@ namespace boost::parser::detail { namespace text { /** Range-friendly version of `std::distance()`, taking an iterator and a sentinel. */ template - std::ptrdiff_t distance(Iter first, Sentinel last) + std::ptrdiff_t distance(Iter first, Sentinel const & last) { return detail::distance( first, @@ -55,7 +55,7 @@ namespace boost::parser::detail { namespace text { /** Range-friendly version of `std::find()`, taking an iterator and a sentinel. */ template - BidiIter find(BidiIter first, Sentinel last, T const & x) + BidiIter find(BidiIter first, Sentinel const & last, T const & x) { while (first != last) { if (*first == x) @@ -68,7 +68,7 @@ namespace boost::parser::detail { namespace text { /** A range-friendly compliment to `std::find()`; returns an iterator to the first element not equal to `x`. */ template - BidiIter find_not(BidiIter first, Sentinel last, T const & x) + BidiIter find_not(BidiIter first, Sentinel const & last, T const & x) { while (first != last) { if (*first != x) @@ -81,7 +81,7 @@ namespace boost::parser::detail { namespace text { /** Range-friendly version of `std::find_if()`, taking an iterator and a sentinel. */ template - BidiIter find_if(BidiIter first, Sentinel last, Pred p) + BidiIter find_if(BidiIter first, Sentinel const & last, Pred p) { while (first != last) { if (p(*first)) @@ -94,7 +94,7 @@ namespace boost::parser::detail { namespace text { /** Range-friendly version of `std::find_if_not()`, taking an iterator and a sentinel. */ template - BidiIter find_if_not(BidiIter first, Sentinel last, Pred p) + BidiIter find_if_not(BidiIter first, Sentinel const & last, Pred p) { while (first != last) { if (!p(*first)) @@ -166,7 +166,7 @@ namespace boost::parser::detail { namespace text { the first element of the subsequence. Subranges passed to `f` are non-overlapping. */ template - Func foreach_subrange(FwdIter first, Sentinel last, Func f) + Func foreach_subrange(FwdIter first, Sentinel const & last, Func f) { while (first != last) { auto const & x = *first; @@ -185,7 +185,7 @@ namespace boost::parser::detail { namespace text { `proj(e)` each compares equal to `proj()` of the first element of the subsequence. Subranges passed to `f` are non-overlapping. */ template - Func foreach_subrange(FwdIter first, Sentinel last, Func f, Proj proj) + Func foreach_subrange(FwdIter first, Sentinel const & last, Func f, Proj proj) { using value_type = typename std::iterator_traits::value_type; while (first != last) { @@ -207,7 +207,7 @@ namespace boost::parser::detail { namespace text { is a contiguous subsequence of elements, each of which is equal to `x`. Subranges passed to `f` are non-overlapping. */ template - Func foreach_subrange_of(FwdIter first, Sentinel last, T const & x, Func f) + Func foreach_subrange_of(FwdIter first, Sentinel const & last, T const & x, Func f) { while (first != last) { first = boost::parser::detail::text::find(first, last, x); @@ -225,7 +225,7 @@ namespace boost::parser::detail { namespace text { is a contiguous subsequence of elements `ei` for which `p(ei)` is true. Subranges passed to `f` are non-overlapping. */ template - Func foreach_subrange_if(FwdIter first, Sentinel last, Pred p, Func f) + Func foreach_subrange_if(FwdIter first, Sentinel const & last, Pred p, Func f) { while (first != last) { first = boost::parser::detail::text::find_if(first, last, p); @@ -241,7 +241,7 @@ namespace boost::parser::detail { namespace text { /** Sentinel-friendly version of `std::all_of()`. */ template - bool all_of(Iter first, Sentinel last, Pred p) + bool all_of(Iter first, Sentinel const & last, Pred p) { for (; first != last; ++first) { if (!p(*first)) @@ -256,7 +256,7 @@ namespace boost::parser::detail { namespace text { typename Sentinel1, typename Iter2, typename Sentinel2> - bool equal(Iter1 first1, Sentinel1 last1, Iter2 first2, Sentinel2 last2) + bool equal(Iter1 first1, Sentinel1 const & last1, Iter2 first2, Sentinel2 const & last2) { for (; first1 != last1 && first2 != last2; ++first1, ++first2) { if (*first1 != *first2) @@ -272,7 +272,7 @@ namespace boost::parser::detail { namespace text { typename Iter2, typename Sentinel2> std::pair - mismatch(Iter1 first1, Sentinel1 last1, Iter2 first2, Sentinel2 last2) + mismatch(Iter1 first1, Sentinel1 const & last1, Iter2 first2, Sentinel2 const & last2) { for (; first1 != last1 && first2 != last2; ++first1, ++first2) { if (*first1 != *first2) @@ -290,7 +290,10 @@ namespace boost::parser::detail { namespace text { typename Iter2, typename Sentinel2> int lexicographical_compare_three_way( - Iter1 first1, Sentinel1 last1, Iter2 first2, Sentinel2 last2) + Iter1 first1, + Sentinel1 const & last1, + Iter2 first2, + Sentinel2 const & last2) { auto const iters = boost::parser::detail::text::mismatch(first1, last1, first2, last2); if (iters.first == last1) { diff --git a/include/boost/parser/detail/text/transcode_algorithm.hpp b/include/boost/parser/detail/text/transcode_algorithm.hpp index a8b869c0..b65276be 100644 --- a/include/boost/parser/detail/text/transcode_algorithm.hpp +++ b/include/boost/parser/detail/text/transcode_algorithm.hpp @@ -81,7 +81,7 @@ namespace boost::parser::detail { namespace text { typename OutIter> transcode_result transcode_utf_8_to_16( InputIter first, - Sentinel last, + Sentinel const & last, std::ptrdiff_t n, OutIter out, std::input_iterator_tag) @@ -103,7 +103,7 @@ namespace boost::parser::detail { namespace text { template transcode_result transcode_utf_8_to_16( Iter first, - Iter last, + Iter const & last, std::ptrdiff_t n, OutIter out, std::random_access_iterator_tag) @@ -119,7 +119,7 @@ namespace boost::parser::detail { namespace text { typename OutIter> transcode_result transcode_utf_8_to_32( InputIter first, - Sentinel last, + Sentinel const & last, std::ptrdiff_t n, OutIter out, std::input_iterator_tag) @@ -141,7 +141,7 @@ namespace boost::parser::detail { namespace text { template transcode_result transcode_utf_8_to_32( Iter first, - Iter last, + Iter const & last, std::ptrdiff_t n, OutIter out, std::random_access_iterator_tag) @@ -158,7 +158,7 @@ namespace boost::parser::detail { namespace text { transcode_result transcode_to_8( tag_t, Iter first, - Sentinel last, + Sentinel const & last, std::ptrdiff_t n, OutIter out) { @@ -173,7 +173,7 @@ namespace boost::parser::detail { namespace text { transcode_result transcode_to_16( tag_t, Iter first, - Sentinel last, + Sentinel const & last, std::ptrdiff_t n, OutIter out) { @@ -189,7 +189,7 @@ namespace boost::parser::detail { namespace text { transcode_result transcode_to_32( tag_t, Iter first, - Sentinel last, + Sentinel const & last, std::ptrdiff_t n, OutIter out) { @@ -205,7 +205,7 @@ namespace boost::parser::detail { namespace text { transcode_result transcode_to_8( tag_t, Iter first, - Sentinel last, + Sentinel const & last, std::ptrdiff_t n, OutIter out) { @@ -247,7 +247,7 @@ namespace boost::parser::detail { namespace text { transcode_result transcode_to_16( tag_t, Iter first, - Sentinel last, + Sentinel const & last, std::ptrdiff_t n, OutIter out) { @@ -261,7 +261,7 @@ namespace boost::parser::detail { namespace text { transcode_result transcode_to_32( tag_t, Iter first, - Sentinel last, + Sentinel const & last, std::ptrdiff_t n, OutIter out) { @@ -304,7 +304,7 @@ namespace boost::parser::detail { namespace text { transcode_result transcode_to_8( tag_t, Iter first, - Sentinel last, + Sentinel const & last, std::ptrdiff_t n, OutIter out) { @@ -318,7 +318,7 @@ namespace boost::parser::detail { namespace text { transcode_result transcode_to_16( tag_t, Iter first, - Sentinel last, + Sentinel const & last, std::ptrdiff_t n, OutIter out) { @@ -332,7 +332,7 @@ namespace boost::parser::detail { namespace text { transcode_result transcode_to_32( tag_t, Iter first, - Sentinel last, + Sentinel const & last, std::ptrdiff_t n, OutIter out) { From 284a42843d8bdca2db1f7b87f67edcbbcb659df1 Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Wed, 10 Dec 2025 17:51:04 +0100 Subject: [PATCH 7/8] pass end iterator by const-ref --- include/boost/parser/parser.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/parser/parser.hpp b/include/boost/parser/parser.hpp index 3e8e55c3..a3c1f7cf 100644 --- a/include/boost/parser/parser.hpp +++ b/include/boost/parser/parser.hpp @@ -455,7 +455,7 @@ namespace boost { namespace parser { static constexpr bool do_trace = DoTrace; static constexpr bool use_callbacks = UseCallbacks; - I first_; + I const & first_; S const & last_; bool * pass_ = nullptr; int * trace_indent_ = nullptr; @@ -524,7 +524,7 @@ namespace boost { namespace parser { parse_context( std::bool_constant, std::bool_constant, - I & first, + I const & first, S const & last, bool & success, int & indent, @@ -547,7 +547,7 @@ namespace boost { namespace parser { parse_context( std::bool_constant, std::bool_constant, - I & first, + I const & first, S const & last, bool & success, int & indent, @@ -565,7 +565,7 @@ namespace boost { namespace parser { parse_context( std::bool_constant, std::bool_constant, - I & first, + I const & first, S const & last, bool & success, int & indent, From 870b07eca1334d924030a3417dcd73c2fb3803cc Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Wed, 10 Dec 2025 18:22:27 +0100 Subject: [PATCH 8/8] pass end iterator by const-ref --- include/boost/parser/detail/text/algorithm.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/boost/parser/detail/text/algorithm.hpp b/include/boost/parser/detail/text/algorithm.hpp index 09660a52..058aa584 100644 --- a/include/boost/parser/detail/text/algorithm.hpp +++ b/include/boost/parser/detail/text/algorithm.hpp @@ -21,7 +21,7 @@ namespace boost::parser::detail { namespace text { namespace detail { template - std::ptrdiff_t distance(Iter first, Iter const & last, non_sentinel_tag) + std::ptrdiff_t distance(Iter const & first, Iter const & last, non_sentinel_tag) { return std::distance(first, last); } @@ -41,7 +41,7 @@ namespace boost::parser::detail { namespace text { /** Range-friendly version of `std::distance()`, taking an iterator and a sentinel. */ template - std::ptrdiff_t distance(Iter first, Sentinel const & last) + std::ptrdiff_t distance(Iter const & first, Sentinel const & last) { return detail::distance( first, @@ -107,7 +107,7 @@ namespace boost::parser::detail { namespace text { /** Analogue of `std::find()` that finds the last value in `[first, last)` equal to `x`. */ template - BidiIter find_backward(BidiIter first, BidiIter last, T const & x) + BidiIter find_backward(BidiIter const & first, BidiIter const & last, T const & x) { auto it = last; while (it != first) { @@ -120,7 +120,7 @@ namespace boost::parser::detail { namespace text { /** Analogue of `std::find()` that finds the last value in `[first, last)` not equal to `x`. */ template - BidiIter find_not_backward(BidiIter first, BidiIter last, T const & x) + BidiIter find_not_backward(BidiIter const & first, BidiIter const & last, T const & x) { auto it = last; while (it != first) { @@ -133,7 +133,7 @@ namespace boost::parser::detail { namespace text { /** Analogue of `std::find()` that finds the last value `v` in `[first, last)` for which `p(v)` is true. */ template - BidiIter find_if_backward(BidiIter first, BidiIter last, Pred p) + BidiIter find_if_backward(BidiIter const & first, BidiIter const & last, Pred p) { auto it = last; while (it != first) { @@ -146,7 +146,7 @@ namespace boost::parser::detail { namespace text { /** Analogue of `std::find()` that finds the last value `v` in `[first, last)` for which `p(v)` is false. */ template - BidiIter find_if_not_backward(BidiIter first, BidiIter last, Pred p) + BidiIter find_if_not_backward(BidiIter const & first, BidiIter const & last, Pred p) { auto it = last; while (it != first) { @@ -290,9 +290,9 @@ namespace boost::parser::detail { namespace text { typename Iter2, typename Sentinel2> int lexicographical_compare_three_way( - Iter1 first1, + Iter1 const & first1, Sentinel1 const & last1, - Iter2 first2, + Iter2 const & first2, Sentinel2 const & last2) { auto const iters = boost::parser::detail::text::mismatch(first1, last1, first2, last2);