parsi/fn/optional.hpp

namespace parsi

Functions

template<is_parser F>
constexpr auto optional(F &&parser) noexcept -> fn::Optional<std::remove_cvref_t<F>>

Creates an optional parser out of given parser that will return a valid succeeded result with the original stream if the parser fails.

See also

fn::Optional

namespace fn
template<is_parser F>
struct Optional
#include <optional.hpp>

Makes a parser to be optional and resort back to original stream if the given parser fails to parse, otherwise it will return the succeeded parse result.

This parser combinator will always succeed and never fail.

Public Functions

inline constexpr auto operator()(Stream stream) const noexcept -> Result

Public Members

std::remove_cvref_t<F> parser