Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Struct template opt_parser

boost::parser::opt_parser

Synopsis

// In header: <boost/parser/parser.hpp>

template<typename Parser> 
struct opt_parser {

  // public member functions
  template<typename Iter, typename Sentinel, typename Context, 
           typename SkipParser> 
    auto call(Iter &, Sentinel, Context const &, SkipParser const &, 
              unspecified, bool &) const;
  template<typename Iter, typename Sentinel, typename Context, 
           typename SkipParser, typename Attribute> 
    void call(Iter &, Sentinel, Context const &, SkipParser const &, 
              unspecified, bool &, Attribute &) const;

  // public data members
  Parser parser_;
};

Description

Repeats the application of another parser of type Parser, [0, 1] times. The parse always succeeds. The attribute produced is a std::optional<T>, where T is the type of attribute produced by Parser.

opt_parser public member functions

  1. template<typename Iter, typename Sentinel, typename Context, 
             typename SkipParser> 
      auto call(Iter & first, Sentinel last, Context const & context, 
                SkipParser const & skip, unspecified flags, bool & success) const;
  2. template<typename Iter, typename Sentinel, typename Context, 
             typename SkipParser, typename Attribute> 
      void call(Iter & first, Sentinel last, Context const & context, 
                SkipParser const & skip, unspecified flags, bool & success, 
                Attribute & retval) const;

PrevUpHomeNext