boost::urls::grammar::variant_rule

Match one of a set of rules

Synopsis

Declared in <boost/url/grammar/variant_rule.hpp>
template<
    Rule R0,
    Rule... Rn>
constexpr
/* implementation-defined */
variant_rule(
    R0 const& r0,
    Rn const...&... rn) noexcept;


Description

Each specified rule is tried in sequence. When the first match occurs, the result is stored and returned in the variant. If no match occurs, an error is returned.

Value Type

using value_type = variant< typename Rules::value_type... >;

Example

Rules are used with the function parse.

// request-target = origin-form // / absolute-form // / authority-form // / asterisk-form system::result< variant< url_view, url_view, authority_view, core::string_view > > rv = grammar::parse( "/index.html?width=full", variant_rule( origin_form_rule, absolute_uri_rule, authority_rule, delim_rule('*') ) );

BNF

variant = rule1 / rule2 / rule3...

Specification

Return Value

The variant rule

Parameters

Name Description
r0 The first rule to match
rn A list of one or more rules to match

See Also

absolute_uri_rule, authority_rule, delim_rule, parse, origin_form_rule, url_view.

Created with MrDocs