[#boost-urls-grammar-variant_rule] = xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/grammar.adoc[grammar]::variant_rule :relfileprefix: ../../../ :mrdocs: Match one of a set of rules == Synopsis Declared in `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/grammar/variant_rule.hpp#L101[boost/url/grammar/variant_rule.hpp]>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< xref:boost/urls/grammar/Rule.adoc[Rule] R0, xref:boost/urls/grammar/Rule.adoc[Rule]... Rn> constexpr /* implementation-defined */::xref:boost/urls/grammar/implementation_defined/variant_rule_t.adoc[variant_rule_t]<R0, Rn...> 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 [,cpp] ---- using value_type = variant< typename Rules::value_type... >; ---- === Example Rules are used with the function xref:boost/urls/grammar/parse-02.adoc[parse]. [,cpp] ---- // 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 [,cpp] ---- variant = rule1 / rule2 / rule3... ---- === Specification * link:https://datatracker.ietf.org/doc/html/rfc5234#section-3.2[3.2. Alternatives (rfc5234)] * link:https://datatracker.ietf.org/doc/html/rfc7230#section-5.3[5.3. Request Target (rfc7230)] == See Also xref:boost/urls/absolute_uri_rule.adoc[absolute_uri_rule], xref:boost/urls/authority_rule.adoc[authority_rule], xref:boost/urls/grammar/delim_rule-01.adoc[delim_rule], xref:boost/urls/grammar/parse-02.adoc[parse], xref:boost/urls/origin_form_rule.adoc[origin_form_rule], xref:boost/urls/url_view.adoc[url_view]. [.small]#Created with https://www.mrdocs.com[MrDocs]#