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 a snapshot of the master branch, built from commit 68cc668162.
PrevUpHomeNext

grammar::optional_rule

Match a rule, or the empty string.

Synopsis

Defined in header <boost/url/grammar/optional_rule.hpp>

template<
    class Rule>
constexpr implementation-defined
optional_rule(
    Rule r);
Description

Optional BNF elements are denoted with square brackets. If the specified rule returns any error it is treated as if the rule did not match.

Value Type
using value_type = optional< typename Rule::value_type >;
Example

Rules are used with the function grammar::parse.

system::result< optional< core::string_view > > rv = parse( "" , optional_rule( token_rule( alpha_chars ) ) );
BNF
optional     = [ rule ]
Specification
Parameters

Name

Description

r

The rule to match

See Also

alpha_chars, parse, optional, token_rule.

Convenience header <boost/url/grammar.hpp>


PrevUpHomeNext