11 template<
typename Parser,
typename Fun>
12 class AndThenParser :
public ParserBase<AndThenParser<Parser, Fun>> {
14 template<
typename P,
typename F>
15 constexpr explicit AndThenParser(InPlace, P&& parser, F&& function)
16 : m_parser(util::forward<P>(parser)), m_function(util::forward<F>(function)) {}
18 template<concepts::ParserContext Context,
typename Value = meta::ParserValue<Context, Parser>>
19 requires(concepts::Parser<Parser, Context>)
20 constexpr auto parse(Context& context)
const {
22 if constexpr (concepts::LanguageVoid<Value>) {
23 return m_parser.parse(context).and_then([&] {
24 return m_function(context) |
if_error([&](
auto&&) {
25 context.advance(begin_save);
29 return m_parser.parse(context).and_then([&](Value&& value) {
30 return m_function(context, util::forward<Value>(value)) |
if_error([&](
auto&&) {
31 context.advance(begin_save);
42 struct AndThenFunction {
43 template<concepts::DecayConstructible Parser, concepts::DecayConstructible Fun>
44 constexpr auto operator()(Parser&& parser, Fun&& function)
const {
46 util::forward<Fun>(function));
51constexpr inline auto and_then = detail::AndThenFunction {};
53template<concepts::DecayConstructible Parser, concepts::DecayConstructible Fun>
Definition operations.h:114
constexpr auto begin
Definition begin.h:52
Definition code_point_parser.h:10
constexpr auto and_then
Definition and_then.h:51
constexpr auto parse
Definition parse.h:23
constexpr auto if_error
Definition if_error.h:28
constexpr auto in_place
Definition in_place.h:8