4.6.0
Freundlich's C++ toolkit
Loading...
Searching...
No Matches
fcppt::parse::optional< Parser > Class Template Reference

Detailed Description

template<typename Parser>
class fcppt::parse::optional< Parser >

Makes a parser optional.

Let p be a parser and let o = optional{p}. First, o saves the current position pos and then tries p. If p succeeds, then its result is returned. Otherwise, o backtracks to pos. If the returned error is fatal, then o also returns it. Otherwise, o returns the empty optional.

Inheritance diagram for fcppt::parse::optional< Parser >:
fcppt::parse::tag

Public Types

using result_type = fcppt::optional::object<fcppt::parse::result_of<Parser>>
 

Public Member Functions

 optional (Parser &&)
 
template<typename Ch , typename Skipper >
fcppt::parse::result< Ch, result_typeparse (fcppt::reference< fcppt::parse::basic_stream< Ch > >, Skipper const &) const
 

Member Typedef Documentation

◆ result_type

template<typename Parser >
using fcppt::parse::optional< Parser >::result_type = fcppt::optional::object<fcppt::parse::result_of<Parser>>

Constructor & Destructor Documentation

◆ optional()

template<typename Parser >
fcppt::parse::optional< Parser >::optional ( Parser && )
explicit

Member Function Documentation

◆ parse()

template<typename Parser >
template<typename Ch , typename Skipper >
fcppt::parse::result< Ch, result_type > fcppt::parse::optional< Parser >::parse ( fcppt::reference< fcppt::parse::basic_stream< Ch > > ,
Skipper const &  ) const
nodiscard