3 <meta http-equiv=
"Content-Type" content=
"text/html; charset=US-ASCII">
4 <title>match_results
</title>
5 <link rel=
"stylesheet" href=
"../../../../../../doc/src/boostbook.css" type=
"text/css">
6 <meta name=
"generator" content=
"DocBook XSL Stylesheets V1.77.1">
7 <link rel=
"home" href=
"../../index.html" title=
"Boost.Regex 5.1.2">
8 <link rel=
"up" href=
"../ref.html" title=
"Reference">
9 <link rel=
"prev" href=
"basic_regex.html" title=
"basic_regex">
10 <link rel=
"next" href=
"sub_match.html" title=
"sub_match">
12 <body bgcolor=
"white" text=
"black" link=
"#0000FF" vlink=
"#840084" alink=
"#0000FF">
13 <table cellpadding=
"2" width=
"100%"><tr>
14 <td valign=
"top"><img alt=
"Boost C++ Libraries" width=
"277" height=
"86" src=
"../../../../../../boost.png"></td>
15 <td align=
"center"><a href=
"../../../../../../index.html">Home
</a></td>
16 <td align=
"center"><a href=
"../../../../../../libs/libraries.htm">Libraries
</a></td>
17 <td align=
"center"><a href=
"http://www.boost.org/users/people.html">People
</a></td>
18 <td align=
"center"><a href=
"http://www.boost.org/users/faq.html">FAQ
</a></td>
19 <td align=
"center"><a href=
"../../../../../../more/index.htm">More
</a></td>
22 <div class=
"spirit-nav">
23 <a accesskey=
"p" href=
"basic_regex.html"><img src=
"../../../../../../doc/src/images/prev.png" alt=
"Prev"></a><a accesskey=
"u" href=
"../ref.html"><img src=
"../../../../../../doc/src/images/up.png" alt=
"Up"></a><a accesskey=
"h" href=
"../../index.html"><img src=
"../../../../../../doc/src/images/home.png" alt=
"Home"></a><a accesskey=
"n" href=
"sub_match.html"><img src=
"../../../../../../doc/src/images/next.png" alt=
"Next"></a>
26 <div class=
"titlepage"><div><div><h3 class=
"title">
27 <a name=
"boost_regex.ref.match_results"></a><a class=
"link" href=
"match_results.html" title=
"match_results">match_results
</a>
28 </h3></div></div></div>
30 <a name=
"boost_regex.ref.match_results.h0"></a>
31 <span class=
"phrase"><a name=
"boost_regex.ref.match_results.synopsis"></a></span><a class=
"link" href=
"match_results.html#boost_regex.ref.match_results.synopsis">Synopsis
</a>
33 <pre class=
"programlisting"><span class=
"preprocessor">#include
</span> <span class=
"special"><</span><span class=
"identifier">boost
</span><span class=
"special">/
</span><span class=
"identifier">regex
</span><span class=
"special">.
</span><span class=
"identifier">hpp
</span><span class=
"special">></span>
36 Regular expressions are different from many simple pattern-matching algorithms
37 in that as well as finding an overall match they can also produce sub-expression
38 matches: each sub-expression being delimited in the pattern by a pair of
39 parenthesis (...). There has to be some method for reporting sub-expression
40 matches back to the user: this is achieved this by defining a class
<code class=
"computeroutput"><span class=
"identifier">match_results
</span></code> that acts as an indexed collection
41 of sub-expression matches, each sub-expression match being contained in an
42 object of type
<a class=
"link" href=
"sub_match.html" title=
"sub_match"><code class=
"computeroutput"><span class=
"identifier">sub_match
</span></code></a>.
45 Template class
<code class=
"computeroutput"><span class=
"identifier">match_results
</span></code>
46 denotes a collection of character sequences representing the result of a
47 regular expression match. Objects of type
<code class=
"computeroutput"><span class=
"identifier">match_results
</span></code>
48 are passed to the algorithms
<a class=
"link" href=
"regex_match.html" title=
"regex_match"><code class=
"computeroutput"><span class=
"identifier">regex_match
</span></code></a> and
<a class=
"link" href=
"regex_search.html" title=
"regex_search"><code class=
"computeroutput"><span class=
"identifier">regex_search
</span></code></a>, and are returned by
49 the iterator
<a class=
"link" href=
"regex_iterator.html" title=
"regex_iterator"><code class=
"computeroutput"><span class=
"identifier">regex_iterator
</span></code></a>. Storage for the
50 collection is allocated and freed as necessary by the member functions of
51 class
<code class=
"computeroutput"><span class=
"identifier">match_results
</span></code>.
54 The template class
<code class=
"computeroutput"><span class=
"identifier">match_results
</span></code>
55 conforms to the requirements of a Sequence, as specified in (lib.sequence.reqmts),
56 except that only operations defined for const-qualified Sequences are supported.
59 Class template
<code class=
"computeroutput"><span class=
"identifier">match_results
</span></code>
60 is most commonly used as one of the typedefs
<code class=
"computeroutput"><span class=
"identifier">cmatch
</span></code>,
61 <code class=
"computeroutput"><span class=
"identifier">wcmatch
</span></code>,
<code class=
"computeroutput"><span class=
"identifier">smatch
</span></code>,
62 or
<code class=
"computeroutput"><span class=
"identifier">wsmatch
</span></code>:
64 <pre class=
"programlisting"><span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span>
65 <span class=
"keyword">class
</span> <span class=
"identifier">Allocator
</span> <span class=
"special">=
</span> <span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">allocator
</span><span class=
"special"><</span><span class=
"identifier">sub_match
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">></span> <span class=
"special">></span>
66 <span class=
"keyword">class
</span> <span class=
"identifier">match_results
</span><span class=
"special">;
</span>
68 <span class=
"keyword">typedef
</span> <span class=
"identifier">match_results
</span><span class=
"special"><</span><span class=
"keyword">const
</span> <span class=
"keyword">char
</span><span class=
"special">*
></span> <span class=
"identifier">cmatch
</span><span class=
"special">;
</span>
69 <span class=
"keyword">typedef
</span> <span class=
"identifier">match_results
</span><span class=
"special"><</span><span class=
"keyword">const
</span> <span class=
"keyword">wchar_t
</span><span class=
"special">*
></span> <span class=
"identifier">wcmatch
</span><span class=
"special">;
</span>
70 <span class=
"keyword">typedef
</span> <span class=
"identifier">match_results
</span><span class=
"special"><</span><span class=
"identifier">string
</span><span class=
"special">::
</span><span class=
"identifier">const_iterator
</span><span class=
"special">></span> <span class=
"identifier">smatch
</span><span class=
"special">;
</span>
71 <span class=
"keyword">typedef
</span> <span class=
"identifier">match_results
</span><span class=
"special"><</span><span class=
"identifier">wstring
</span><span class=
"special">::
</span><span class=
"identifier">const_iterator
</span><span class=
"special">></span> <span class=
"identifier">wsmatch
</span><span class=
"special">;
</span>
73 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span>
74 <span class=
"keyword">class
</span> <span class=
"identifier">Allocator
</span> <span class=
"special">=
</span> <span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">allocator
</span><span class=
"special"><</span><span class=
"identifier">sub_match
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">></span> <span class=
"special">></span>
75 <span class=
"keyword">class
</span> <span class=
"identifier">match_results
</span>
76 <span class=
"special">{
</span>
77 <span class=
"keyword">public
</span><span class=
"special">:
</span>
78 <span class=
"keyword">typedef
</span> <span class=
"identifier">sub_match
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">></span> <span class=
"identifier">value_type
</span><span class=
"special">;
</span>
79 <span class=
"keyword">typedef
</span> <span class=
"keyword">const
</span> <span class=
"identifier">value_type
</span><span class=
"special">&</span> <span class=
"identifier">const_reference
</span><span class=
"special">;
</span>
80 <span class=
"keyword">typedef
</span> <span class=
"identifier">const_reference
</span> <span class=
"identifier">reference
</span><span class=
"special">;
</span>
81 <span class=
"keyword">typedef
</span> <span class=
"identifier">implementation
</span> <span class=
"identifier">defined
</span> <span class=
"identifier">const_iterator
</span><span class=
"special">;
</span>
82 <span class=
"keyword">typedef
</span> <span class=
"identifier">const_iterator
</span> <span class=
"identifier">iterator
</span><span class=
"special">;
</span>
83 <span class=
"keyword">typedef
</span> <span class=
"keyword">typename
</span> <span class=
"identifier">iterator_traits
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">>::
</span><span class=
"identifier">difference_type
</span> <span class=
"identifier">difference_type
</span><span class=
"special">;
</span>
84 <span class=
"keyword">typedef
</span> <span class=
"keyword">typename
</span> <span class=
"identifier">Allocator
</span><span class=
"special">::
</span><span class=
"identifier">size_type
</span> <span class=
"identifier">size_type
</span><span class=
"special">;
</span>
85 <span class=
"keyword">typedef
</span> <span class=
"identifier">Allocator
</span> <span class=
"identifier">allocator_type
</span><span class=
"special">;
</span>
86 <span class=
"keyword">typedef
</span> <span class=
"keyword">typename
</span> <span class=
"identifier">iterator_traits
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">>::
</span><span class=
"identifier">value_type
</span> <span class=
"identifier">char_type
</span><span class=
"special">;
</span>
87 <span class=
"keyword">typedef
</span> <span class=
"identifier">basic_string
</span><span class=
"special"><</span><span class=
"identifier">char_type
</span><span class=
"special">></span> <span class=
"identifier">string_type
</span><span class=
"special">;
</span>
89 <span class=
"comment">// construct/copy/destroy:
</span>
90 <a class=
"link" href=
"match_results.html#boost_regex.match_results.construct">explicit match_results
</a><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">Allocator
</span><span class=
"special">&</span> <span class=
"identifier">a
</span> <span class=
"special">=
</span> <span class=
"identifier">Allocator
</span><span class=
"special">());
</span>
91 <a class=
"link" href=
"match_results.html#boost_regex.match_results.copy_construct">match_results
</a><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">match_results
</span><span class=
"special">&</span> <span class=
"identifier">m
</span><span class=
"special">);
</span>
92 <a class=
"link" href=
"match_results.html#boost_regex.match_results.assign">match_results
& operator=
</a><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">match_results
</span><span class=
"special">&</span> <span class=
"identifier">m
</span><span class=
"special">);
</span>
93 <span class=
"special">~
</span><span class=
"identifier">match_results
</span><span class=
"special">();
</span>
95 <span class=
"comment">// size:
</span>
96 <span class=
"identifier">size_type
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.size">size
</a><span class=
"special">()
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
97 <span class=
"identifier">size_type
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.max_size">max_size
</a><span class=
"special">()
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
98 <span class=
"keyword">bool
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.empty">empty
</a><span class=
"special">()
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
99 <span class=
"comment">// element access:
</span>
100 <span class=
"identifier">difference_type
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.length">length
</a><span class=
"special">(
</span><span class=
"keyword">int
</span> <span class=
"identifier">sub
</span> <span class=
"special">=
</span> <span class=
"number">0</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
101 <span class=
"identifier">difference_type
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.length">length
</a><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">char_type
</span><span class=
"special">*
</span> <span class=
"identifier">sub
</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
102 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">charT
</span><span class=
"special">></span>
103 <span class=
"identifier">difference_type
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.length">length
</a><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">charT
</span><span class=
"special">*
</span> <span class=
"identifier">sub
</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
104 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">A
</span><span class=
"special">></span>
105 <span class=
"identifier">difference_type
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.length">length
</a><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">basic_string
</span><span class=
"special"><</span><span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"identifier">A
</span><span class=
"special">>&</span> <span class=
"identifier">sub
</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
106 <span class=
"identifier">difference_type
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.position">position
</a><span class=
"special">(
</span><span class=
"keyword">unsigned
</span> <span class=
"keyword">int
</span> <span class=
"identifier">sub
</span> <span class=
"special">=
</span> <span class=
"number">0</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
107 <span class=
"identifier">difference_type
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.position">position
</a><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">char_type
</span><span class=
"special">*
</span> <span class=
"identifier">sub
</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
108 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">charT
</span><span class=
"special">></span>
109 <span class=
"identifier">difference_type
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.position">position
</a><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">charT
</span><span class=
"special">*
</span> <span class=
"identifier">sub
</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
110 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">A
</span><span class=
"special">></span>
111 <span class=
"identifier">difference_type
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.position">position
</a><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">basic_string
</span><span class=
"special"><</span><span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"identifier">A
</span><span class=
"special">>&</span> <span class=
"identifier">sub
</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
112 <span class=
"identifier">string_type
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.str">str
</a><span class=
"special">(
</span><span class=
"keyword">int
</span> <span class=
"identifier">sub
</span> <span class=
"special">=
</span> <span class=
"number">0</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
113 <span class=
"identifier">string_type
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.str">str
</a><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">char_type
</span><span class=
"special">*
</span> <span class=
"identifier">sub
</span><span class=
"special">)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
114 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">A
</span><span class=
"special">></span>
115 <span class=
"identifier">string_type
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.str">str
</a><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">basic_string
</span><span class=
"special"><</span><span class=
"identifier">char_type
</span><span class=
"special">,
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"identifier">A
</span><span class=
"special">>&</span> <span class=
"identifier">sub
</span><span class=
"special">)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
116 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">charT
</span><span class=
"special">></span>
117 <span class=
"identifier">string_type
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.str">str
</a><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">charT
</span><span class=
"special">*
</span> <span class=
"identifier">sub
</span><span class=
"special">)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
118 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">A
</span><span class=
"special">></span>
119 <span class=
"identifier">string_type
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.str">str
</a><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">basic_string
</span><span class=
"special"><</span><span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"identifier">A
</span><span class=
"special">>&</span> <span class=
"identifier">sub
</span><span class=
"special">)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
120 <span class=
"identifier">const_reference
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.subscript">operator[]
</a><span class=
"special">(
</span><span class=
"keyword">int
</span> <span class=
"identifier">n
</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
121 <span class=
"identifier">const_reference
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.subscript">operator[]
</a><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">char_type
</span><span class=
"special">*
</span> <span class=
"identifier">n
</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
122 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">A
</span><span class=
"special">></span>
123 <span class=
"identifier">const_reference
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.subscript">operator[]
</a><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">basic_string
</span><span class=
"special"><</span><span class=
"identifier">char_type
</span><span class=
"special">,
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"identifier">A
</span><span class=
"special">>&</span> <span class=
"identifier">n
</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
124 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">charT
</span><span class=
"special">></span>
125 <span class=
"identifier">const_reference
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.subscript">operator[]
</a><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">charT
</span><span class=
"special">*
</span> <span class=
"identifier">n
</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
126 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">A
</span><span class=
"special">></span>
127 <span class=
"identifier">const_reference
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.subscript">operator[]
</a><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">basic_string
</span><span class=
"special"><</span><span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"identifier">A
</span><span class=
"special">>&</span> <span class=
"identifier">n
</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
129 <span class=
"identifier">const_reference
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.prefix">prefix
</a><span class=
"special">()
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
131 <span class=
"identifier">const_reference
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.suffix">suffix
</a><span class=
"special">()
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
132 <span class=
"identifier">const_iterator
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.begin">begin
</a><span class=
"special">()
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
133 <span class=
"identifier">const_iterator
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.end">end
</a><span class=
"special">()
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
134 <span class=
"comment">// format:
</span>
135 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">OutputIterator
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">Formatter
</span><span class=
"special">></span>
136 <span class=
"identifier">OutputIterator
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.format">format
</a><span class=
"special">(
</span><span class=
"identifier">OutputIterator
</span> <span class=
"identifier">out
</span><span class=
"special">,
</span>
137 <span class=
"identifier">Formatter
</span> <span class=
"identifier">fmt
</span><span class=
"special">,
</span>
138 <span class=
"identifier">match_flag_type
</span> <span class=
"identifier">flags
</span> <span class=
"special">=
</span> <span class=
"identifier">format_default
</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
139 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">Formatter
</span><span class=
"special">></span>
140 <span class=
"identifier">string_type
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.format2">format
</a><span class=
"special">(
</span><span class=
"identifier">Formatter
</span> <span class=
"identifier">fmt
</span><span class=
"special">,
</span>
141 <span class=
"identifier">match_flag_type
</span> <span class=
"identifier">flags
</span> <span class=
"special">=
</span> <span class=
"identifier">format_default
</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
143 <span class=
"identifier">allocator_type
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.get_allocator">get_allocator
</a><span class=
"special">()
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
144 <span class=
"keyword">void
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.swap">swap
</a><span class=
"special">(
</span><span class=
"identifier">match_results
</span><span class=
"special">&</span> <span class=
"identifier">that
</span><span class=
"special">);
</span>
146 <span class=
"preprocessor">#ifdef
</span> <span class=
"identifier">BOOST_REGEX_MATCH_EXTRA
</span>
147 <span class=
"keyword">typedef
</span> <span class=
"keyword">typename
</span> <span class=
"identifier">value_type
</span><span class=
"special">::
</span><span class=
"identifier">capture_sequence_type
</span> <span class=
"identifier">capture_sequence_type
</span><span class=
"special">;
</span>
148 <span class=
"keyword">const
</span> <span class=
"identifier">capture_sequence_type
</span><span class=
"special">&</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.captures">captures
</a><span class=
"special">(
</span><span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">size_t
</span> <span class=
"identifier">i
</span><span class=
"special">)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
149 <span class=
"preprocessor">#endif
</span>
151 <span class=
"special">};
</span>
153 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">Allocator
</span><span class=
"special">></span>
154 <span class=
"keyword">bool
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.op_eq">operator ==
</a> <span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">match_results
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"identifier">Allocator
</span><span class=
"special">>&</span> <span class=
"identifier">m1
</span><span class=
"special">,
</span>
155 <span class=
"keyword">const
</span> <span class=
"identifier">match_results
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"identifier">Allocator
</span><span class=
"special">>&</span> <span class=
"identifier">m2
</span><span class=
"special">);
</span>
156 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">Allocator
</span><span class=
"special">></span>
157 <span class=
"keyword">bool
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.op_ne">operator !=
</a> <span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">match_results
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"identifier">Allocator
</span><span class=
"special">>&</span> <span class=
"identifier">m1
</span><span class=
"special">,
</span>
158 <span class=
"keyword">const
</span> <span class=
"identifier">match_results
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"identifier">Allocator
</span><span class=
"special">>&</span> <span class=
"identifier">m2
</span><span class=
"special">);
</span>
160 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">traits
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">Allocator
</span><span class=
"special">></span>
161 <span class=
"identifier">basic_ostream
</span><span class=
"special"><</span><span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"identifier">traits
</span><span class=
"special">>&</span>
162 <a class=
"link" href=
"match_results.html#boost_regex.match_results.op_stream">operator
<<</a> <span class=
"special">(
</span><span class=
"identifier">basic_ostream
</span><span class=
"special"><</span><span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"identifier">traits
</span><span class=
"special">>&</span> <span class=
"identifier">os
</span><span class=
"special">,
</span>
163 <span class=
"keyword">const
</span> <span class=
"identifier">match_results
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"identifier">Allocator
</span><span class=
"special">>&</span> <span class=
"identifier">m
</span><span class=
"special">);
</span>
165 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">Allocator
</span><span class=
"special">></span>
166 <span class=
"keyword">void
</span> <a class=
"link" href=
"match_results.html#boost_regex.match_results.op_swap">swap
</a><span class=
"special">(
</span><span class=
"identifier">match_results
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"identifier">Allocator
</span><span class=
"special">>&</span> <span class=
"identifier">m1
</span><span class=
"special">,
</span>
167 <span class=
"identifier">match_results
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"identifier">Allocator
</span><span class=
"special">>&</span> <span class=
"identifier">m2
</span><span class=
"special">);
</span>
170 <a name=
"boost_regex.ref.match_results.h1"></a>
171 <span class=
"phrase"><a name=
"boost_regex.ref.match_results.description"></a></span><a class=
"link" href=
"match_results.html#boost_regex.ref.match_results.description">Description
</a>
174 In all
<code class=
"computeroutput"><span class=
"identifier">match_results
</span></code> constructors,
175 a copy of the Allocator argument is used for any memory allocation performed
176 by the constructor or member functions during the lifetime of the object.
178 <a name=
"boost_regex.match_results.construct"></a><pre class=
"programlisting"><span class=
"identifier">match_results
</span><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">Allocator
</span><span class=
"special">&</span> <span class=
"identifier">a
</span> <span class=
"special">=
</span> <span class=
"identifier">Allocator
</span><span class=
"special">());
</span>
181 <span class=
"bold"><strong>Effects
</strong></span>: Constructs an object of class
182 <code class=
"computeroutput"><span class=
"identifier">match_results
</span></code>. The postconditions
183 of this function are indicated in the table:
185 <div class=
"informaltable"><table class=
"table">
235 basic_string
<charT
>()
241 <a name=
"boost_regex.match_results.copy_construct"></a><pre class=
"programlisting"><span class=
"identifier">match_results
</span><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">match_results
</span><span class=
"special">&</span> <span class=
"identifier">m
</span><span class=
"special">);
</span>
244 <span class=
"bold"><strong>Effects
</strong></span>: Constructs an object of class match_results,
247 <a name=
"boost_regex.match_results.assign"></a><pre class=
"programlisting"><span class=
"identifier">match_results
</span><span class=
"special">&</span> <span class=
"keyword">operator
</span><span class=
"special">=(
</span><span class=
"keyword">const
</span> <span class=
"identifier">match_results
</span><span class=
"special">&</span> <span class=
"identifier">m
</span><span class=
"special">);
</span>
250 <span class=
"bold"><strong>Effects
</strong></span>: Assigns m to *this. The postconditions
251 of this function are indicated in the table:
253 <div class=
"informaltable"><table class=
"table">
303 m.str(n) for all integers n
< m.size().
339 m[n] for all integers n
< m.size().
351 m.length(n) for all integers n
< m.size().
363 m.position(n) for all integers n
< m.size().
369 <a name=
"boost_regex.match_results.size"></a><pre class=
"programlisting"><span class=
"identifier">size_type
</span> <span class=
"identifier">size
</span><span class=
"special">()
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
372 <span class=
"bold"><strong>Effects
</strong></span>: Returns the number of
<a class=
"link" href=
"sub_match.html" title=
"sub_match"><code class=
"computeroutput"><span class=
"identifier">sub_match
</span></code></a> elements stored in *this;
373 that is the number of marked sub-expressions in the regular expression that
374 was matched plus one.
376 <a name=
"boost_regex.match_results.max_size"></a><pre class=
"programlisting"><span class=
"identifier">size_type
</span> <span class=
"identifier">max_size
</span><span class=
"special">()
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
379 <span class=
"bold"><strong>Effects
</strong></span>: Returns the maximum number of
380 <a class=
"link" href=
"sub_match.html" title=
"sub_match"><code class=
"computeroutput"><span class=
"identifier">sub_match
</span></code></a>
381 elements that can be stored in *this.
383 <a name=
"boost_regex.match_results.empty"></a><pre class=
"programlisting"><span class=
"keyword">bool
</span> <span class=
"identifier">empty
</span><span class=
"special">()
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
386 <span class=
"bold"><strong>Effects
</strong></span>: Returns size() ==
0.
388 <a name=
"boost_regex.match_results.length"></a><pre class=
"programlisting"><span class=
"identifier">difference_type
</span> <span class=
"identifier">length
</span><span class=
"special">(
</span><span class=
"keyword">int
</span> <span class=
"identifier">sub
</span> <span class=
"special">=
</span> <span class=
"number">0</span><span class=
"special">)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
389 <span class=
"identifier">difference_type
</span> <span class=
"identifier">length
</span><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">char_type
</span><span class=
"special">*
</span> <span class=
"identifier">sub
</span><span class=
"special">)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
390 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">charT
</span><span class=
"special">></span>
391 <span class=
"identifier">difference_type
</span> <span class=
"identifier">length
</span><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">charT
</span><span class=
"special">*
</span> <span class=
"identifier">sub
</span><span class=
"special">)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
392 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">A
</span><span class=
"special">></span>
393 <span class=
"identifier">difference_type
</span> <span class=
"identifier">length
</span><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">basic_string
</span><span class=
"special"><</span><span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"identifier">A
</span><span class=
"special">>&)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
396 <span class=
"bold"><strong>Requires
</strong></span>: that the match_results object
397 has been initialized as a result of a successful call to
<a class=
"link" href=
"regex_search.html" title=
"regex_search"><code class=
"computeroutput"><span class=
"identifier">regex_search
</span></code></a> or
<a class=
"link" href=
"regex_match.html" title=
"regex_match"><code class=
"computeroutput"><span class=
"identifier">regex_match
</span></code></a> or was returned from
398 a
<a class=
"link" href=
"regex_iterator.html" title=
"regex_iterator"><code class=
"computeroutput"><span class=
"identifier">regex_iterator
</span></code></a>,
399 and that the underlying iterators have not been subsequently invalidated.
400 Will raise a
<code class=
"computeroutput"><span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">logic_error
</span></code> if the match_results object
404 <span class=
"bold"><strong>Effects
</strong></span>: Returns the length of sub-expression
405 <span class=
"emphasis"><em>sub
</em></span>, that is to say:
<code class=
"computeroutput"><span class=
"special">(*
</span><span class=
"keyword">this
</span><span class=
"special">)[
</span><span class=
"identifier">sub
</span><span class=
"special">].
</span><span class=
"identifier">length
</span><span class=
"special">()
</span></code>.
408 The overloads that accept a string refer to a named sub-expression
<span class=
"emphasis"><em>n
</em></span>.
409 In the event that there is no such named sub-expression then returns zero.
412 The template overloads of this function, allow the string and/or character
413 type to be different from the character type of the underlying sequence and/or
414 regular expression: in this case the characters will be widened to the underlying
415 character type of the original regular expression. A compiler error will
416 occur if the argument passes a wider character type than the underlying sequence.
417 These overloads allow a normal narrow character C string literal to be used
418 as an argument, even when the underlying character type of the expression
419 being matched may be something more exotic such as a Unicode character type.
421 <a name=
"boost_regex.match_results.position"></a><pre class=
"programlisting"><span class=
"identifier">difference_type
</span> <span class=
"identifier">position
</span><span class=
"special">(
</span><span class=
"keyword">unsigned
</span> <span class=
"keyword">int
</span> <span class=
"identifier">sub
</span> <span class=
"special">=
</span> <span class=
"number">0</span><span class=
"special">)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
422 <span class=
"identifier">difference_type
</span> <span class=
"identifier">position
</span><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">char_type
</span><span class=
"special">*
</span> <span class=
"identifier">sub
</span><span class=
"special">)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
423 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">charT
</span><span class=
"special">></span>
424 <span class=
"identifier">difference_type
</span> <span class=
"identifier">position
</span><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">charT
</span><span class=
"special">*
</span> <span class=
"identifier">sub
</span><span class=
"special">)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
425 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">A
</span><span class=
"special">></span>
426 <span class=
"identifier">difference_type
</span> <span class=
"identifier">position
</span><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">basic_string
</span><span class=
"special"><</span><span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"identifier">A
</span><span class=
"special">>&)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
429 <span class=
"bold"><strong>Requires
</strong></span>: that the match_results object
430 has been initialized as a result of a successful call to
<a class=
"link" href=
"regex_search.html" title=
"regex_search"><code class=
"computeroutput"><span class=
"identifier">regex_search
</span></code></a> or
<a class=
"link" href=
"regex_match.html" title=
"regex_match"><code class=
"computeroutput"><span class=
"identifier">regex_match
</span></code></a> or was returned from
431 a
<a class=
"link" href=
"regex_iterator.html" title=
"regex_iterator"><code class=
"computeroutput"><span class=
"identifier">regex_iterator
</span></code></a>,
432 and that the underlying iterators have not been subsequently invalidated.
433 Will raise a
<code class=
"computeroutput"><span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">logic_error
</span></code> if the match_results object
437 <span class=
"bold"><strong>Effects
</strong></span>: Returns the starting location of
438 sub-expression
<span class=
"emphasis"><em>sub
</em></span>, or -
1 if
<span class=
"emphasis"><em>sub
</em></span>
439 was not matched. Note that if this represents a partial match , then
<code class=
"computeroutput"><span class=
"identifier">position
</span><span class=
"special">()
</span></code>
440 will return the location of the partial match even though
<code class=
"computeroutput"><span class=
"special">(*
</span><span class=
"keyword">this
</span><span class=
"special">)[
</span><span class=
"number">0</span><span class=
"special">].
</span><span class=
"identifier">matched
</span></code>
444 The overloads that accept a string refer to a named sub-expression
<span class=
"emphasis"><em>n
</em></span>.
445 In the event that there is no such named sub-expression then returns -
1.
448 The template overloads of this function, allow the string and/or character
449 type to be different from the character type of the underlying sequence and/or
450 regular expression: in this case the characters will be widened to the underlying
451 character type of the original regular expression. A compiler error will
452 occur if the argument passes a wider character type than the underlying sequence.
453 These overloads allow a normal narrow character C string literal to be used
454 as an argument, even when the underlying character type of the expression
455 being matched may be something more exotic such as a Unicode character type.
457 <a name=
"boost_regex.match_results.str"></a><pre class=
"programlisting"><span class=
"identifier">string_type
</span> <span class=
"identifier">str
</span><span class=
"special">(
</span><span class=
"keyword">int
</span> <span class=
"identifier">sub
</span> <span class=
"special">=
</span> <span class=
"number">0</span><span class=
"special">)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
458 <span class=
"identifier">string_type
</span> <span class=
"identifier">str
</span><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">char_type
</span><span class=
"special">*
</span> <span class=
"identifier">sub
</span><span class=
"special">)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
459 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">A
</span><span class=
"special">></span>
460 <span class=
"identifier">string_type
</span> <span class=
"identifier">str
</span><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">basic_string
</span><span class=
"special"><</span><span class=
"identifier">char_type
</span><span class=
"special">,
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"identifier">A
</span><span class=
"special">>&</span> <span class=
"identifier">sub
</span><span class=
"special">)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
461 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">charT
</span><span class=
"special">></span>
462 <span class=
"identifier">string_type
</span> <span class=
"identifier">str
</span><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">charT
</span><span class=
"special">*
</span> <span class=
"identifier">sub
</span><span class=
"special">)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
463 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">A
</span><span class=
"special">></span>
464 <span class=
"identifier">string_type
</span> <span class=
"identifier">str
</span><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">basic_string
</span><span class=
"special"><</span><span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"identifier">A
</span><span class=
"special">>&</span> <span class=
"identifier">sub
</span><span class=
"special">)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
467 <span class=
"bold"><strong>Requires
</strong></span>: that the match_results object
468 has been initialized as a result of a successful call to
<a class=
"link" href=
"regex_search.html" title=
"regex_search"><code class=
"computeroutput"><span class=
"identifier">regex_search
</span></code></a> or
<a class=
"link" href=
"regex_match.html" title=
"regex_match"><code class=
"computeroutput"><span class=
"identifier">regex_match
</span></code></a> or was returned from
469 a
<a class=
"link" href=
"regex_iterator.html" title=
"regex_iterator"><code class=
"computeroutput"><span class=
"identifier">regex_iterator
</span></code></a>,
470 and that the underlying iterators have not been subsequently invalidated.
471 Will raise a
<code class=
"computeroutput"><span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">logic_error
</span></code> if the match_results object
475 <span class=
"bold"><strong>Effects
</strong></span>: Returns sub-expression
<span class=
"emphasis"><em>sub
</em></span>
476 as a string:
<code class=
"computeroutput"><span class=
"identifier">string_type
</span><span class=
"special">((*
</span><span class=
"keyword">this
</span><span class=
"special">)[
</span><span class=
"identifier">sub
</span><span class=
"special">])
</span></code>.
479 The overloads that accept a string, return the string that matched the named
480 sub-expression
<span class=
"emphasis"><em>n
</em></span>. In the event that there is no such
481 named sub-expression then returns an empty string.
484 The template overloads of this function, allow the string and/or character
485 type to be different from the character type of the underlying sequence and/or
486 regular expression: in this case the characters will be widened to the underlying
487 character type of the original regular expression. A compiler error will
488 occur if the argument passes a wider character type than the underlying sequence.
489 These overloads allow a normal narrow character C string literal to be used
490 as an argument, even when the underlying character type of the expression
491 being matched may be something more exotic such as a Unicode character type.
493 <a name=
"boost_regex.match_results.subscript"></a><pre class=
"programlisting"><span class=
"identifier">const_reference
</span> <span class=
"keyword">operator
</span><span class=
"special">[](
</span><span class=
"keyword">int
</span> <span class=
"identifier">n
</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
494 <span class=
"identifier">const_reference
</span> <span class=
"keyword">operator
</span><span class=
"special">[](
</span><span class=
"keyword">const
</span> <span class=
"identifier">char_type
</span><span class=
"special">*
</span> <span class=
"identifier">n
</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
495 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">A
</span><span class=
"special">></span>
496 <span class=
"identifier">const_reference
</span> <span class=
"keyword">operator
</span><span class=
"special">[](
</span><span class=
"keyword">const
</span> <span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">basic_string
</span><span class=
"special"><</span><span class=
"identifier">char_type
</span><span class=
"special">,
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"identifier">A
</span><span class=
"special">>&</span> <span class=
"identifier">n
</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
497 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">charT
</span><span class=
"special">></span>
498 <span class=
"identifier">const_reference
</span> <span class=
"keyword">operator
</span><span class=
"special">[](
</span><span class=
"keyword">const
</span> <span class=
"identifier">charT
</span><span class=
"special">*
</span> <span class=
"identifier">n
</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
499 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">A
</span><span class=
"special">></span>
500 <span class=
"identifier">const_reference
</span> <span class=
"keyword">operator
</span><span class=
"special">[](
</span><span class=
"keyword">const
</span> <span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">basic_string
</span><span class=
"special"><</span><span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"identifier">Traits
</span><span class=
"special">,
</span> <span class=
"identifier">A
</span><span class=
"special">>&</span> <span class=
"identifier">n
</span><span class=
"special">)
</span> <span class=
"keyword">const
</span><span class=
"special">;
</span>
503 <span class=
"bold"><strong>Requires
</strong></span>: that the match_results object
504 has been initialized as a result of a successful call to
<a class=
"link" href=
"regex_search.html" title=
"regex_search"><code class=
"computeroutput"><span class=
"identifier">regex_search
</span></code></a> or
<a class=
"link" href=
"regex_match.html" title=
"regex_match"><code class=
"computeroutput"><span class=
"identifier">regex_match
</span></code></a> or was returned from
505 a
<a class=
"link" href=
"regex_iterator.html" title=
"regex_iterator"><code class=
"computeroutput"><span class=
"identifier">regex_iterator
</span></code></a>,
506 and that the underlying iterators have not been subsequently invalidated.
507 Will raise a
<code class=
"computeroutput"><span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">logic_error
</span></code> if the match_results object
511 <span class=
"bold"><strong>Effects
</strong></span>: Returns a reference to the
<a class=
"link" href=
"sub_match.html" title=
"sub_match"><code class=
"computeroutput"><span class=
"identifier">sub_match
</span></code></a>
512 object representing the character sequence that matched marked sub-expression
513 <span class=
"emphasis"><em>n
</em></span>. If
<code class=
"computeroutput"><span class=
"identifier">n
</span> <span class=
"special">==
</span> <span class=
"number">0</span></code> then returns
514 a reference to a
<a class=
"link" href=
"sub_match.html" title=
"sub_match"><code class=
"computeroutput"><span class=
"identifier">sub_match
</span></code></a> object representing the
515 character sequence that matched the whole regular expression. If
<span class=
"emphasis"><em>n
</em></span>
516 is out of range, or if
<span class=
"emphasis"><em>n
</em></span> is an unmatched sub-expression,
517 then returns a
<a class=
"link" href=
"sub_match.html" title=
"sub_match"><code class=
"computeroutput"><span class=
"identifier">sub_match
</span></code></a>
518 object whose matched member is false.
521 The overloads that accept a string, return a reference to the
<a class=
"link" href=
"sub_match.html" title=
"sub_match"><code class=
"computeroutput"><span class=
"identifier">sub_match
</span></code></a> object representing the
522 character sequence that matched the named sub-expression
<span class=
"emphasis"><em>n
</em></span>.
523 In the event that there is no such named sub-expression then returns a
<a class=
"link" href=
"sub_match.html" title=
"sub_match"><code class=
"computeroutput"><span class=
"identifier">sub_match
</span></code></a>
524 object whose matched member is false.
527 The template overloads of this function, allow the string and/or character
528 type to be different from the character type of the underlying sequence and/or
529 regular expression: in this case the characters will be widened to the underlying
530 character type of the original regular expression. A compiler error will
531 occur if the argument passes a wider character type than the underlying sequence.
532 These overloads allow a normal narrow character C string literal to be used
533 as an argument, even when the underlying character type of the expression
534 being matched may be something more exotic such as a Unicode character type.
536 <a name=
"boost_regex.match_results.prefix"></a><pre class=
"programlisting"><span class=
"identifier">const_reference
</span> <span class=
"identifier">prefix
</span><span class=
"special">()
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
539 <span class=
"bold"><strong>Requires
</strong></span>: that the match_results object
540 has been initialized as a result of a successful call to
<a class=
"link" href=
"regex_search.html" title=
"regex_search"><code class=
"computeroutput"><span class=
"identifier">regex_search
</span></code></a> or
<a class=
"link" href=
"regex_match.html" title=
"regex_match"><code class=
"computeroutput"><span class=
"identifier">regex_match
</span></code></a> or was returned from
541 a
<a class=
"link" href=
"regex_iterator.html" title=
"regex_iterator"><code class=
"computeroutput"><span class=
"identifier">regex_iterator
</span></code></a>,
542 and that the underlying iterators have not been subsequently invalidated.
543 Will raise a
<code class=
"computeroutput"><span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">logic_error
</span></code> if the match_results object
547 <span class=
"bold"><strong>Effects
</strong></span>: Returns a reference to the
<a class=
"link" href=
"sub_match.html" title=
"sub_match"><code class=
"computeroutput"><span class=
"identifier">sub_match
</span></code></a>
548 object representing the character sequence from the start of the string being
549 matched or searched, to the start of the match found.
551 <a name=
"boost_regex.match_results.suffix"></a><pre class=
"programlisting"><span class=
"identifier">const_reference
</span> <span class=
"identifier">suffix
</span><span class=
"special">()
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
554 <span class=
"bold"><strong>Requires
</strong></span>: that the match_results object
555 has been initialized as a result of a successful call to
<a class=
"link" href=
"regex_search.html" title=
"regex_search"><code class=
"computeroutput"><span class=
"identifier">regex_search
</span></code></a> or
<a class=
"link" href=
"regex_match.html" title=
"regex_match"><code class=
"computeroutput"><span class=
"identifier">regex_match
</span></code></a> or was returned from
556 a
<a class=
"link" href=
"regex_iterator.html" title=
"regex_iterator"><code class=
"computeroutput"><span class=
"identifier">regex_iterator
</span></code></a>,
557 and that the underlying iterators have not been subsequently invalidated.
558 Will raise a
<code class=
"computeroutput"><span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">logic_error
</span></code> if the match_results object
562 <span class=
"bold"><strong>Effects
</strong></span>: Returns a reference to the
<a class=
"link" href=
"sub_match.html" title=
"sub_match"><code class=
"computeroutput"><span class=
"identifier">sub_match
</span></code></a>
563 object representing the character sequence from the end of the match found
564 to the end of the string being matched or searched.
566 <a name=
"boost_regex.match_results.begin"></a><pre class=
"programlisting"><span class=
"identifier">const_iterator
</span> <span class=
"identifier">begin
</span><span class=
"special">()
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
569 <span class=
"bold"><strong>Effects
</strong></span>: Returns a starting iterator that
570 enumerates over all the marked sub-expression matches stored in *this.
572 <a name=
"boost_regex.match_results.end"></a><pre class=
"programlisting"><span class=
"identifier">const_iterator
</span> <span class=
"identifier">end
</span><span class=
"special">()
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
575 <span class=
"bold"><strong>Effects
</strong></span>: Returns a terminating iterator
576 that enumerates over all the marked sub-expression matches stored in *this.
578 <a name=
"boost_regex.match_results_format"></a><a name=
"boost_regex.match_results.format"></a><pre class=
"programlisting"><span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">OutputIterator
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">Formatter
</span><span class=
"special">></span>
579 <span class=
"identifier">OutputIterator
</span> <span class=
"identifier">format
</span><span class=
"special">(
</span><span class=
"identifier">OutputIterator
</span> <span class=
"identifier">out
</span><span class=
"special">,
</span>
580 <span class=
"identifier">Formatter
</span> <span class=
"identifier">fmt
</span><span class=
"special">,
</span>
581 <span class=
"identifier">match_flag_type
</span> <span class=
"identifier">flags
</span> <span class=
"special">=
</span> <span class=
"identifier">format_default
</span><span class=
"special">);
</span>
584 <span class=
"bold"><strong>Requires
</strong></span>: The type
<code class=
"computeroutput"><span class=
"identifier">OutputIterator
</span></code>
585 conforms to the Output Iterator requirements (C++ std
24.1.2).
588 The type
<code class=
"computeroutput"><span class=
"identifier">Formatter
</span></code> must be
589 either a pointer to a null-terminated string of type
<code class=
"computeroutput"><span class=
"identifier">char_type
</span><span class=
"special">[]
</span></code>, or be a container of
<code class=
"computeroutput"><span class=
"identifier">char_type
</span></code>'s
590 (for example
<code class=
"computeroutput"><span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">basic_string
</span><span class=
"special"><</span><span class=
"identifier">char_type
</span><span class=
"special">></span></code>)
591 or be a unary, binary or ternary functor that computes the replacement string
592 from a function call: either
<code class=
"computeroutput"><span class=
"identifier">fmt
</span><span class=
"special">(*
</span><span class=
"keyword">this
</span><span class=
"special">)
</span></code>
593 which must return a container of
<code class=
"computeroutput"><span class=
"identifier">char_type
</span></code>'s
594 to be used as the replacement text, or either
<code class=
"computeroutput"><span class=
"identifier">fmt
</span><span class=
"special">(*
</span><span class=
"keyword">this
</span><span class=
"special">,
</span>
595 <span class=
"identifier">out
</span><span class=
"special">)
</span></code>
596 or
<code class=
"computeroutput"><span class=
"identifier">fmt
</span><span class=
"special">(*
</span><span class=
"keyword">this
</span><span class=
"special">,
</span> <span class=
"identifier">out
</span><span class=
"special">,
</span> <span class=
"identifier">flags
</span><span class=
"special">)
</span></code>, both of which write the replacement text
597 to
<code class=
"computeroutput"><span class=
"special">*
</span><span class=
"identifier">out
</span></code>,
598 and then return the new OutputIterator position. Note that if the formatter
599 is a functor, then it is
<span class=
"emphasis"><em>passed by value
</em></span>: users that
600 want to pass function objects with internal state might want to use
<a href=
"../../../../../../doc/html/ref.html" target=
"_top">Boost.Ref
</a> to wrap the object
601 so that it's passed by reference.
604 <span class=
"bold"><strong>Requires
</strong></span>: that the match_results object
605 has been initialized as a result of a successful call to
<a class=
"link" href=
"regex_search.html" title=
"regex_search"><code class=
"computeroutput"><span class=
"identifier">regex_search
</span></code></a> or
<a class=
"link" href=
"regex_match.html" title=
"regex_match"><code class=
"computeroutput"><span class=
"identifier">regex_match
</span></code></a> or was returned from
606 a
<a class=
"link" href=
"regex_iterator.html" title=
"regex_iterator"><code class=
"computeroutput"><span class=
"identifier">regex_iterator
</span></code></a>,
607 and that the underlying iterators have not been subsequently invalidated.
608 Will raise a
<code class=
"computeroutput"><span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">logic_error
</span></code> if the match_results object
612 <span class=
"bold"><strong>Effects
</strong></span>: If
<code class=
"computeroutput"><span class=
"identifier">fmt
</span></code>
613 is either a null-terminated string, or a container of
<code class=
"computeroutput"><span class=
"identifier">char_type
</span></code>'s,
614 then copies the character sequence
<code class=
"computeroutput"><span class=
"special">[
</span><span class=
"identifier">fmt
</span><span class=
"special">.
</span><span class=
"identifier">begin
</span><span class=
"special">(),
</span> <span class=
"identifier">fmt
</span><span class=
"special">.
</span><span class=
"identifier">end
</span><span class=
"special">())
</span></code>
615 to
<code class=
"computeroutput"><span class=
"identifier">OutputIterator
</span></code> <span class=
"emphasis"><em>out
</em></span>.
616 For each format specifier or escape sequence in
<span class=
"emphasis"><em>fmt
</em></span>,
617 replace that sequence with either the character(s) it represents, or the
618 sequence of characters within
<code class=
"computeroutput"><span class=
"special">*
</span><span class=
"keyword">this
</span></code> to which it refers. The bitmasks specified
619 in flags determines what format specifiers or escape sequences are recognized,
620 by default this is the format used by ECMA-
262, ECMAScript Language Specification,
621 Chapter
15 part
5.4.11 String.prototype.replace.
624 If
<code class=
"computeroutput"><span class=
"identifier">fmt
</span></code> is a function object,
625 then depending on the number of arguments the function object accepts, it
628 <div class=
"itemizedlist"><ul class=
"itemizedlist" style=
"list-style-type: disc; ">
629 <li class=
"listitem">
630 Call
<code class=
"computeroutput"><span class=
"identifier">fmt
</span><span class=
"special">(*
</span><span class=
"keyword">this
</span><span class=
"special">)
</span></code>
631 and copy the string returned to
<code class=
"computeroutput"><span class=
"identifier">OutputIterator
</span></code>
632 <span class=
"emphasis"><em>out
</em></span>.
634 <li class=
"listitem">
635 Call
<code class=
"computeroutput"><span class=
"identifier">fmt
</span><span class=
"special">(*
</span><span class=
"keyword">this
</span><span class=
"special">,
</span> <span class=
"identifier">out
</span><span class=
"special">)
</span></code>.
637 <li class=
"listitem">
638 Call
<code class=
"computeroutput"><span class=
"identifier">fmt
</span><span class=
"special">(*
</span><span class=
"keyword">this
</span><span class=
"special">,
</span> <span class=
"identifier">out
</span><span class=
"special">,
</span> <span class=
"identifier">flags
</span><span class=
"special">)
</span></code>.
642 In all cases the new position of the
<code class=
"computeroutput"><span class=
"identifier">OutputIterator
</span></code>
646 See the
<a class=
"link" href=
"../format.html" title=
"Search and Replace Format String Syntax">format syntax guide for more information
</a>.
649 <span class=
"bold"><strong>Returns
</strong></span>: out.
651 <a name=
"boost_regex.match_results.format2"></a><pre class=
"programlisting"><span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">Formatter
</span><span class=
"special">></span>
652 <span class=
"identifier">string_type
</span> <span class=
"identifier">format
</span><span class=
"special">(
</span><span class=
"identifier">Formatter
</span> <span class=
"identifier">fmt
</span><span class=
"special">,
</span>
653 <span class=
"identifier">match_flag_type
</span> <span class=
"identifier">flags
</span> <span class=
"special">=
</span> <span class=
"identifier">format_default
</span><span class=
"special">);
</span>
656 <span class=
"bold"><strong>Requires
</strong></span> The type
<code class=
"computeroutput"><span class=
"identifier">Formatter
</span></code>
657 must be either a pointer to a null-terminated string of type
<code class=
"computeroutput"><span class=
"identifier">char_type
</span><span class=
"special">[]
</span></code>,
658 or be a container of
<code class=
"computeroutput"><span class=
"identifier">char_type
</span></code>'s
659 (for example
<code class=
"computeroutput"><span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">basic_string
</span><span class=
"special"><</span><span class=
"identifier">char_type
</span><span class=
"special">></span></code>)
660 or be a unary, binary or ternary functor that computes the replacement string
661 from a function call: either
<code class=
"computeroutput"><span class=
"identifier">fmt
</span><span class=
"special">(*
</span><span class=
"keyword">this
</span><span class=
"special">)
</span></code>
662 which must return a container of
<code class=
"computeroutput"><span class=
"identifier">char_type
</span></code>'s
663 to be used as the replacement text, or either
<code class=
"computeroutput"><span class=
"identifier">fmt
</span><span class=
"special">(*
</span><span class=
"keyword">this
</span><span class=
"special">,
</span>
664 <span class=
"identifier">out
</span><span class=
"special">)
</span></code>
665 or
<code class=
"computeroutput"><span class=
"identifier">fmt
</span><span class=
"special">(*
</span><span class=
"keyword">this
</span><span class=
"special">,
</span> <span class=
"identifier">out
</span><span class=
"special">,
</span> <span class=
"identifier">flags
</span><span class=
"special">)
</span></code>, both of which write the replacement text
666 to
<code class=
"computeroutput"><span class=
"special">*
</span><span class=
"identifier">out
</span></code>,
667 and then return the new OutputIterator position.
670 <span class=
"bold"><strong>Requires
</strong></span>: that the match_results object
671 has been initialized as a result of a successful call to
<a class=
"link" href=
"regex_search.html" title=
"regex_search"><code class=
"computeroutput"><span class=
"identifier">regex_search
</span></code></a> or
<a class=
"link" href=
"regex_match.html" title=
"regex_match"><code class=
"computeroutput"><span class=
"identifier">regex_match
</span></code></a> or was returned from
672 a
<a class=
"link" href=
"regex_iterator.html" title=
"regex_iterator"><code class=
"computeroutput"><span class=
"identifier">regex_iterator
</span></code></a>,
673 and that the underlying iterators have not been subsequently invalidated.
674 Will raise a
<code class=
"computeroutput"><span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">logic_error
</span></code> if the match_results object
678 <span class=
"bold"><strong>Effects
</strong></span>: If
<code class=
"computeroutput"><span class=
"identifier">fmt
</span></code>
679 is either a null-terminated string, or a container of
<code class=
"computeroutput"><span class=
"identifier">char_type
</span></code>'s,
680 then copies the string
<span class=
"emphasis"><em>fmt
</em></span>: For each format specifier
681 or escape sequence in
<span class=
"emphasis"><em>fmt
</em></span>, replace that sequence with
682 either the character(s) it represents, or the sequence of characters within
683 <code class=
"computeroutput"><span class=
"special">*
</span><span class=
"keyword">this
</span></code>
684 to which it refers. The bitmasks specified in flags determines what format
685 specifiers or escape sequences are recognized, by default this is the format
686 used by ECMA-
262, ECMAScript Language Specification, Chapter
15 part
5.4.11
687 String.prototype.replace.
690 If
<code class=
"computeroutput"><span class=
"identifier">fmt
</span></code> is a function object,
691 then depending on the number of arguments the function object accepts, it
694 <div class=
"itemizedlist"><ul class=
"itemizedlist" style=
"list-style-type: disc; ">
695 <li class=
"listitem">
696 Call
<code class=
"computeroutput"><span class=
"identifier">fmt
</span><span class=
"special">(*
</span><span class=
"keyword">this
</span><span class=
"special">)
</span></code>
697 and return the result.
699 <li class=
"listitem">
700 Call
<code class=
"computeroutput"><span class=
"identifier">fmt
</span><span class=
"special">(*
</span><span class=
"keyword">this
</span><span class=
"special">,
</span> <span class=
"identifier">unspecified
</span><span class=
"special">-
</span><span class=
"identifier">output
</span><span class=
"special">-
</span><span class=
"identifier">iterator
</span><span class=
"special">)
</span></code>,
701 where
<code class=
"computeroutput"><span class=
"identifier">unspecified
</span><span class=
"special">-
</span><span class=
"identifier">output
</span><span class=
"special">-
</span><span class=
"identifier">iterator
</span></code> is an unspecified OutputIterator
702 type used to copy the output to the string result.
704 <li class=
"listitem">
705 Call
<code class=
"computeroutput"><span class=
"identifier">fmt
</span><span class=
"special">(*
</span><span class=
"keyword">this
</span><span class=
"special">,
</span> <span class=
"identifier">unspecified
</span><span class=
"special">-
</span><span class=
"identifier">output
</span><span class=
"special">-
</span><span class=
"identifier">iterator
</span><span class=
"special">,
</span>
706 <span class=
"identifier">flags
</span><span class=
"special">)
</span></code>,
707 where
<code class=
"computeroutput"><span class=
"identifier">unspecified
</span><span class=
"special">-
</span><span class=
"identifier">output
</span><span class=
"special">-
</span><span class=
"identifier">iterator
</span></code> is an unspecified OutputIterator
708 type used to copy the output to the string result.
712 See the
<a class=
"link" href=
"../format.html" title=
"Search and Replace Format String Syntax">format syntax guide for more information
</a>.
714 <a name=
"boost_regex.match_results.get_allocator"></a><pre class=
"programlisting"><span class=
"identifier">allocator_type
</span> <span class=
"identifier">get_allocator
</span><span class=
"special">()
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
717 <span class=
"bold"><strong>Effects
</strong></span>: Returns a copy of the Allocator
718 that was passed to the object's constructor.
720 <a name=
"boost_regex.match_results.swap"></a><pre class=
"programlisting"><span class=
"keyword">void
</span> <span class=
"identifier">swap
</span><span class=
"special">(
</span><span class=
"identifier">match_results
</span><span class=
"special">&</span> <span class=
"identifier">that
</span><span class=
"special">);
</span>
723 <span class=
"bold"><strong>Effects
</strong></span>: Swaps the contents of the two sequences.
726 <span class=
"bold"><strong>Postcondition
</strong></span>: *this contains the sequence
727 of matched sub-expressions that were in that, that contains the sequence
728 of matched sub-expressions that were in *this.
731 <span class=
"bold"><strong>Complexity
</strong></span>: constant time.
733 <a name=
"boost_regex.match_results.capture_type"></a><pre class=
"programlisting"><span class=
"keyword">typedef
</span> <span class=
"keyword">typename
</span> <span class=
"identifier">value_type
</span><span class=
"special">::
</span><span class=
"identifier">capture_sequence_type
</span> <span class=
"identifier">capture_sequence_type
</span><span class=
"special">;
</span>
736 Defines an implementation-specific type that satisfies the requirements of
737 a standard library Sequence (
21.1.1 including the optional Table
68 operations),
738 whose value_type is a
<code class=
"computeroutput"><span class=
"identifier">sub_match
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">></span></code>. This type happens to be
<code class=
"computeroutput"><span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">vector
</span><span class=
"special"><</span><span class=
"identifier">sub_match
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">></span> <span class=
"special">></span></code>,
739 but you shouldn't actually rely on that.
741 <a name=
"boost_regex.match_results.captures"></a><pre class=
"programlisting"><span class=
"keyword">const
</span> <span class=
"identifier">capture_sequence_type
</span><span class=
"special">&</span> <span class=
"identifier">captures
</span><span class=
"special">(
</span><span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">size_t
</span> <span class=
"identifier">i
</span><span class=
"special">)
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
744 <span class=
"bold"><strong>Requires
</strong></span>: that the match_results object
745 has been initialized as a result of a successful call to
<a class=
"link" href=
"regex_search.html" title=
"regex_search"><code class=
"computeroutput"><span class=
"identifier">regex_search
</span></code></a> or
<a class=
"link" href=
"regex_match.html" title=
"regex_match"><code class=
"computeroutput"><span class=
"identifier">regex_match
</span></code></a> or was returned from
746 a
<a class=
"link" href=
"regex_iterator.html" title=
"regex_iterator"><code class=
"computeroutput"><span class=
"identifier">regex_iterator
</span></code></a>,
747 and that the underlying iterators have not been subsequently invalidated.
748 Will raise a
<code class=
"computeroutput"><span class=
"identifier">std
</span><span class=
"special">::
</span><span class=
"identifier">logic_error
</span></code> if the match_results object
752 <span class=
"bold"><strong>Effects
</strong></span>: returns a sequence containing all
753 the captures obtained for sub-expression i.
756 <span class=
"bold"><strong>Returns
</strong></span>:
<code class=
"computeroutput"><span class=
"special">(*
</span><span class=
"keyword">this
</span><span class=
"special">)[
</span><span class=
"identifier">i
</span><span class=
"special">].
</span><span class=
"identifier">captures
</span><span class=
"special">();
</span></code>
759 <span class=
"bold"><strong>Preconditions
</strong></span>: the library must be built
760 and used with BOOST_REGEX_MATCH_EXTRA defined, and you must pass the flag
761 match_extra to the regex matching functions (
<a class=
"link" href=
"regex_match.html" title=
"regex_match"><code class=
"computeroutput"><span class=
"identifier">regex_match
</span></code></a>,
<a class=
"link" href=
"regex_search.html" title=
"regex_search"><code class=
"computeroutput"><span class=
"identifier">regex_search
</span></code></a>,
<a class=
"link" href=
"regex_iterator.html" title=
"regex_iterator"><code class=
"computeroutput"><span class=
"identifier">regex_iterator
</span></code></a> or
<a class=
"link" href=
"regex_token_iterator.html" title=
"regex_token_iterator"><code class=
"computeroutput"><span class=
"identifier">regex_token_iterator
</span></code></a>) in order for
762 this member function to be defined and return useful information.
765 <span class=
"bold"><strong>Rationale
</strong></span>: Enabling this feature has several
768 <div class=
"itemizedlist"><ul class=
"itemizedlist" style=
"list-style-type: disc; ">
769 <li class=
"listitem">
770 sub_match occupies more memory resulting in complex expressions running
771 out of memory or stack space more quickly during matching.
773 <li class=
"listitem">
774 The matching algorithms are less efficient at handling some features
775 (independent sub-expressions for example), even when match_extra is not
778 <li class=
"listitem">
779 The matching algorithms are much less efficient (i.e. slower), when match_extra
780 is used. Mostly this is down to the extra memory allocations that have
784 <a name=
"boost_regex.match_results.op_eq"></a><pre class=
"programlisting"><span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">Allocator
</span><span class=
"special">></span>
785 <span class=
"keyword">bool
</span> <span class=
"keyword">operator
</span> <span class=
"special">==
</span> <span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">match_results
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"identifier">Allocator
</span><span class=
"special">>&</span> <span class=
"identifier">m1
</span><span class=
"special">,
</span>
786 <span class=
"keyword">const
</span> <span class=
"identifier">match_results
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"identifier">Allocator
</span><span class=
"special">>&</span> <span class=
"identifier">m2
</span><span class=
"special">);
</span>
789 <span class=
"bold"><strong>Effects
</strong></span>: Compares the two sequences for
792 <a name=
"boost_regex.match_results.op_ne"></a><pre class=
"programlisting"><span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">Allocator
</span><span class=
"special">></span>
793 <span class=
"keyword">bool
</span> <span class=
"keyword">operator
</span> <span class=
"special">!=
</span> <span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">match_results
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"identifier">Allocator
</span><span class=
"special">>&</span> <span class=
"identifier">m1
</span><span class=
"special">,
</span>
794 <span class=
"keyword">const
</span> <span class=
"identifier">match_results
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"identifier">Allocator
</span><span class=
"special">>&</span> <span class=
"identifier">m2
</span><span class=
"special">);
</span>
797 <span class=
"bold"><strong>Effects
</strong></span>: Compares the two sequences for
800 <a name=
"boost_regex.match_results.op_stream"></a><pre class=
"programlisting"><span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">traits
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">Allocator
</span><span class=
"special">></span>
801 <span class=
"identifier">basic_ostream
</span><span class=
"special"><</span><span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"identifier">traits
</span><span class=
"special">>&</span>
802 <span class=
"keyword">operator
</span> <span class=
"special"><<</span> <span class=
"special">(
</span><span class=
"identifier">basic_ostream
</span><span class=
"special"><</span><span class=
"identifier">charT
</span><span class=
"special">,
</span> <span class=
"identifier">traits
</span><span class=
"special">>&</span> <span class=
"identifier">os
</span><span class=
"special">,
</span>
803 <span class=
"keyword">const
</span> <span class=
"identifier">match_results
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"identifier">Allocator
</span><span class=
"special">>&</span> <span class=
"identifier">m
</span><span class=
"special">);
</span>
806 <span class=
"bold"><strong>Effects
</strong></span>: Writes the contents of
<span class=
"emphasis"><em>m
</em></span>
807 to the stream
<span class=
"emphasis"><em>os
</em></span> as if by calling
<code class=
"computeroutput"><span class=
"identifier">os
</span>
808 <span class=
"special"><<</span> <span class=
"identifier">m
</span><span class=
"special">.
</span><span class=
"identifier">str
</span><span class=
"special">()
</span></code>;
809 Returns
<span class=
"emphasis"><em>os
</em></span>.
811 <a name=
"boost_regex.match_results.op_swap"></a><pre class=
"programlisting"><span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <span class=
"identifier">Allocator
</span><span class=
"special">></span>
812 <span class=
"keyword">void
</span> <span class=
"identifier">swap
</span><span class=
"special">(
</span><span class=
"identifier">match_results
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"identifier">Allocator
</span><span class=
"special">>&</span> <span class=
"identifier">m1
</span><span class=
"special">,
</span>
813 <span class=
"identifier">match_results
</span><span class=
"special"><</span><span class=
"identifier">BidirectionalIterator
</span><span class=
"special">,
</span> <span class=
"identifier">Allocator
</span><span class=
"special">>&</span> <span class=
"identifier">m2
</span><span class=
"special">);
</span>
816 <span class=
"bold"><strong>Effects
</strong></span>: Swaps the contents of the two sequences.
819 <table xmlns:
rev=
"http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width=
"100%"><tr>
820 <td align=
"left"></td>
821 <td align=
"right"><div class=
"copyright-footer">Copyright
© 1998-
2013 John Maddock
<p>
822 Distributed under the Boost Software License, Version
1.0. (See accompanying
823 file LICENSE_1_0.txt or copy at
<a href=
"http://www.boost.org/LICENSE_1_0.txt" target=
"_top">http://www.boost.org/LICENSE_1_0.txt
</a>)
828 <div class=
"spirit-nav">
829 <a accesskey=
"p" href=
"basic_regex.html"><img src=
"../../../../../../doc/src/images/prev.png" alt=
"Prev"></a><a accesskey=
"u" href=
"../ref.html"><img src=
"../../../../../../doc/src/images/up.png" alt=
"Up"></a><a accesskey=
"h" href=
"../../index.html"><img src=
"../../../../../../doc/src/images/home.png" alt=
"Home"></a><a accesskey=
"n" href=
"sub_match.html"><img src=
"../../../../../../doc/src/images/next.png" alt=
"Next"></a>