Added docs for smatch and wsmatch typedefs, added warnings about using temporaries with regex_search/regex_match.

[SVN r11383]
This commit is contained in:
John Maddock
2001-10-13 10:24:55 +00:00
parent 33b6eb0637
commit c4b295684b
2 changed files with 24 additions and 9 deletions

View File

@ -158,12 +158,14 @@ result of a match contains a number of sub-expression matches in
addition to the overall match. When the library needs to report a addition to the overall match. When the library needs to report a
regular expression match it does so using an instance of the regular expression match it does so using an instance of the
class <a href="template_class_ref.htm#reg_match">match_results</a>, class <a href="template_class_ref.htm#reg_match">match_results</a>,
as before there are typedefs of this class for the two most as before there are typedefs of this class for the most common
common cases: </p> cases: </p>
<pre><b>namespace </b>boost{ <pre><b>namespace </b>boost{
<b>typedef</b> match_results&lt;<b>const</b> <b>char</b>*&gt; cmatch; <b>typedef</b> match_results&lt;<b>const</b> <b>char</b>*&gt; cmatch;
<b>typedef</b> match_results&lt;<b>const</b> <b>wchar_t</b>*&gt; wcmatch; <b>typedef</b> match_results&lt;<b>const</b> <b>wchar_t</b>*&gt; wcmatch;
<strong>typedef</strong> match_results&lt;std::string::const_iterator&gt; smatch;
<strong>typedef</strong> match_results&lt;std::wstring::const_iterator&gt; wsmatch;
}</pre> }</pre>
<p>The algorithms <a href="template_class_ref.htm#reg_search">regex_search</a> <p>The algorithms <a href="template_class_ref.htm#reg_search">regex_search</a>

View File

@ -871,7 +871,9 @@ each sub-expression match being contained in an object of type <i>sub_match</i>.
&nbsp;&nbsp; <b>bool</b> <b>operator</b>&lt;(<b>const</b> match_results&amp; that)<b>const</b>; &nbsp;&nbsp; <b>bool</b> <b>operator</b>&lt;(<b>const</b> match_results&amp; that)<b>const</b>;
}; };
<strong>typedef</strong> match_results&lt;<strong>const</strong> <strong>char</strong>*&gt; cmatch; <strong>typedef</strong> match_results&lt;<strong>const</strong> <strong>char</strong>*&gt; cmatch;
<strong>typedef</strong> match_results&lt;<strong>const</strong> <strong>wchar_t</strong>*&gt; wcmatch; </pre> <strong>typedef</strong> match_results&lt;<strong>const</strong> <strong>wchar_t</strong>*&gt; wcmatch;
<strong>typedef</strong> match_results&lt;std::string::const_iterator&gt; smatch;
<strong>typedef</strong> match_results&lt;std::wstring::const_iterator&gt; wsmatch; </pre>
<p>Class match_results is used for reporting what matched a <p>Class match_results is used for reporting what matched a
regular expression, it is passed to the matching algorithms <a regular expression, it is passed to the matching algorithms <a
@ -1128,10 +1130,10 @@ properties. </p>
<p>The algorithm regex _match determines whether a given regular <p>The algorithm regex _match determines whether a given regular
expression matches a given sequence denoted by a pair of expression matches a given sequence denoted by a pair of
bidirectional-iterators, the algorithm is defined as follows, bidirectional-iterators, the algorithm is defined as follows, <em>note
note that the result is true only if the expression matches the that the result is true only if the expression matches the whole
whole of the input sequence, the main use of this function is of the input sequence</em>, the main use of this function is data
data input validation: </p> input validation: </p>
<pre><b>template</b> &lt;<b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT, <b>class</b> traits, <b>class</b> Allocator2&gt; <pre><b>template</b> &lt;<b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT, <b>class</b> traits, <b>class</b> Allocator2&gt;
<b>bool</b> regex_match(iterator first,&nbsp; <b>bool</b> regex_match(iterator first,&nbsp;
@ -1205,7 +1207,12 @@ return true or false and do not indicate what matched: </p>
will be less than or equal to last. m[1] denotes the will be less than or equal to last. m[1] denotes the
first subexpression m[2] the second subexpression and so first subexpression m[2] the second subexpression and so
on. If no match occurred then m[0].first = m[0].second = on. If no match occurred then m[0].first = m[0].second =
last.</td> last.<p>Note that since the match_results structure
stores only iterators, and not strings, the iterators/strings
passed to regex_match must be valid for as long as the
result is to be used. For that reason never pass
temporary string objects to regex_match.</p>
</td>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
<tr> <tr>
@ -1456,7 +1463,13 @@ upon your compilers capabilities]: </p>
that matched, m[0].first and m[0].second will be less that matched, m[0].first and m[0].second will be less
than or equal to last. m[1] denotes the first sub-expression than or equal to last. m[1] denotes the first sub-expression
m[2] the second sub-expression and so on. If no match m[2] the second sub-expression and so on. If no match
occurred then m[0].first = m[0].second = last.</td> occurred then m[0].first = m[0].second = last.<p>Note
that since the match_results structure stores only
iterators, and not strings, the iterators/strings passed
to regex_search must be valid for as long as the result
is to be used. For that reason never pass temporary
string objects to regex_search.</p>
</td>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
<tr> <tr>