1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>basic_static_string::compare (9 of 9 overloads)</title> 5<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../../../index.html" title="Boost.StaticString"> 8<link rel="up" href="../compare.html" title="basic_static_string::compare"> 9<link rel="prev" href="overload8.html" title="basic_static_string::compare (8 of 9 overloads)"> 10<link rel="next" href="../substr.html" title="basic_static_string::substr"> 11</head> 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> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="overload8.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../compare.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="../substr.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h5 class="title"> 27<a name="static_string.ref.boost__static_strings__basic_static_string.compare.overload9"></a><a class="link" href="overload9.html" title="basic_static_string::compare (9 of 9 overloads)">basic_static_string::compare 28 (9 of 9 overloads)</a> 29</h5></div></div></div> 30<p> 31 Compare a string with the string. 32 </p> 33<h6> 34<a name="static_string.ref.boost__static_strings__basic_static_string.compare.overload9.h0"></a> 35 <span class="phrase"><a name="static_string.ref.boost__static_strings__basic_static_string.compare.overload9.synopsis"></a></span><a class="link" href="overload9.html#static_string.ref.boost__static_strings__basic_static_string.compare.overload9.synopsis">Synopsis</a> 36 </h6> 37<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> 38 <span class="special">[</span><span class="identifier">role</span> <span class="identifier">red</span> <span class="identifier">error</span><span class="special">.</span><span class="identifier">param</span> <span class="identifier">neither</span> <span class="identifier">has</span> <span class="identifier">a</span> <span class="identifier">declname</span> <span class="identifier">nor</span> <span class="identifier">a</span> <span class="char">'class '</span> <span class="identifier">prefix</span> <span class="identifier">in</span> <span class="identifier">the</span> <span class="identifier">type</span><span class="special">][</span><span class="identifier">role</span> <span class="identifier">red</span> <span class="identifier">error</span><span class="special">.</span><span class="identifier">param</span> <span class="identifier">neither</span> <span class="identifier">has</span> <span class="identifier">a</span> <span class="identifier">declname</span> <span class="identifier">nor</span> <span class="identifier">a</span> <span class="char">'class '</span> <span class="identifier">prefix</span> <span class="identifier">in</span> <span class="identifier">the</span> <span class="identifier">type</span><span class="special">][</span><span class="identifier">role</span> <span class="identifier">red</span> <span class="identifier">error</span><span class="special">.</span><span class="identifier">param</span> <span class="identifier">neither</span> <span class="identifier">has</span> <span class="identifier">a</span> <span class="identifier">declname</span> <span class="identifier">nor</span> <span class="identifier">a</span> <span class="char">'class '</span> <span class="identifier">prefix</span> <span class="identifier">in</span> <span class="identifier">the</span> <span class="identifier">type</span><span class="special">][</span><span class="identifier">role</span> <span class="identifier">red</span> <span class="identifier">error</span><span class="special">.</span><span class="identifier">param</span> <span class="identifier">neither</span> <span class="identifier">has</span> <span class="identifier">a</span> <span class="identifier">declname</span> <span class="identifier">nor</span> <span class="identifier">a</span> <span class="char">'class '</span> <span class="identifier">prefix</span> <span class="identifier">in</span> <span class="identifier">the</span> <span class="identifier">type</span><span class="special">]></span> 39<span class="keyword">constexpr</span> <span class="keyword">int</span> 40<span class="identifier">compare</span><span class="special">(</span> 41 <span class="identifier">size_type</span> <span class="identifier">pos1</span><span class="special">,</span> 42 <span class="identifier">size_type</span> <span class="identifier">count1</span><span class="special">,</span> 43 <span class="keyword">const</span> <span class="identifier">T</span><span class="special">&</span> <span class="identifier">t</span><span class="special">,</span> 44 <span class="identifier">size_type</span> <span class="identifier">pos2</span><span class="special">,</span> 45 <span class="identifier">size_type</span> <span class="identifier">count2</span> <span class="special">=</span> <a class="link" href="../npos.html" title="basic_static_string::npos">npos</a><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> 46</pre> 47<h6> 48<a name="static_string.ref.boost__static_strings__basic_static_string.compare.overload9.h1"></a> 49 <span class="phrase"><a name="static_string.ref.boost__static_strings__basic_static_string.compare.overload9.description"></a></span><a class="link" href="overload9.html#static_string.ref.boost__static_strings__basic_static_string.compare.overload9.description">Description</a> 50 </h6> 51<p> 52 Let <code class="computeroutput"><span class="identifier">sub1</span></code> be <code class="computeroutput"><span class="identifier">substr</span><span class="special">(</span><span class="identifier">pos1</span><span class="special">,</span> <span class="identifier">count1</span><span class="special">)</span></code>, 53 <code class="computeroutput"><span class="identifier">sub2</span></code> be <code class="computeroutput"><span class="identifier">string_view_type</span><span class="special">(</span><span class="identifier">t</span><span class="special">).</span><span class="identifier">substr</span><span class="special">(</span><span class="identifier">pos2</span><span class="special">,</span> <span class="identifier">count2</span><span class="special">)</span></code>, 54 and <code class="computeroutput"><span class="identifier">comp</span></code> be <code class="computeroutput"><span class="identifier">traits_type</span><span class="special">::</span><span class="identifier">compare</span><span class="special">(</span><span class="identifier">sub1</span><span class="special">.</span><span class="identifier">data</span><span class="special">(),</span> <span class="identifier">sub2</span><span class="special">.</span><span class="identifier">data</span><span class="special">(),</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">min</span><span class="special">(</span><span class="identifier">sub1</span><span class="special">.</span><span class="identifier">size</span><span class="special">(),</span> <span class="identifier">sub2</span><span class="special">.</span><span class="identifier">size</span><span class="special">())</span></code>. 55 If <code class="computeroutput"><span class="identifier">comp</span> <span class="special">!=</span> 56 <span class="number">0</span></code>, then the result is <code class="computeroutput"><span class="identifier">comp</span></code>. Otherwise, the result is <code class="computeroutput"><span class="number">0</span></code> if <code class="computeroutput"><span class="identifier">sub1</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span> <span class="special">==</span> <span class="identifier">sub2</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code>, 57 <code class="computeroutput"><span class="special">-</span><span class="number">1</span></code> 58 if <code class="computeroutput"><span class="identifier">sub1</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span> <span class="special"><</span> <span class="identifier">sub2</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code>, and <code class="computeroutput"><span class="number">1</span></code> 59 otherwise. 60 </p> 61<h6> 62<a name="static_string.ref.boost__static_strings__basic_static_string.compare.overload9.h2"></a> 63 <span class="phrase"><a name="static_string.ref.boost__static_strings__basic_static_string.compare.overload9.complexity"></a></span><a class="link" href="overload9.html#static_string.ref.boost__static_strings__basic_static_string.compare.overload9.complexity">Complexity</a> 64 </h6> 65<p> 66 Linear. 67 </p> 68<h6> 69<a name="static_string.ref.boost__static_strings__basic_static_string.compare.overload9.h3"></a> 70 <span class="phrase"><a name="static_string.ref.boost__static_strings__basic_static_string.compare.overload9.exception_safety"></a></span><a class="link" href="overload9.html#static_string.ref.boost__static_strings__basic_static_string.compare.overload9.exception_safety">Exception 71 Safety</a> 72 </h6> 73<p> 74 Strong guarantee. 75 </p> 76<h6> 77<a name="static_string.ref.boost__static_strings__basic_static_string.compare.overload9.h4"></a> 78 <span class="phrase"><a name="static_string.ref.boost__static_strings__basic_static_string.compare.overload9.template_parameters"></a></span><a class="link" href="overload9.html#static_string.ref.boost__static_strings__basic_static_string.compare.overload9.template_parameters">Template 79 Parameters</a> 80 </h6> 81<div class="informaltable"><table class="table"> 82<colgroup> 83<col> 84<col> 85</colgroup> 86<thead><tr> 87<th> 88 <p> 89 Type 90 </p> 91 </th> 92<th> 93 <p> 94 Description 95 </p> 96 </th> 97</tr></thead> 98<tbody><tr> 99<td> 100 <p> 101 <code class="computeroutput"><span class="identifier">T</span></code> 102 </p> 103 </td> 104<td> 105 <p> 106 The type of the object to convert. 107 </p> 108 </td> 109</tr></tbody> 110</table></div> 111<h6> 112<a name="static_string.ref.boost__static_strings__basic_static_string.compare.overload9.h5"></a> 113 <span class="phrase"><a name="static_string.ref.boost__static_strings__basic_static_string.compare.overload9.constraints"></a></span><a class="link" href="overload9.html#static_string.ref.boost__static_strings__basic_static_string.compare.overload9.constraints">Constraints</a> 114 </h6> 115<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">is_convertible</span><span class="special"><</span><span class="keyword">const</span> <span class="identifier">T</span><span class="special">&,</span> <span class="identifier">string_view</span><span class="special">>::</span><span class="identifier">value</span> <span class="special">&&</span> 116<span class="special">!</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">is_convertible</span><span class="special"><</span><span class="keyword">const</span> <span class="identifier">T</span><span class="special">&,</span> <span class="identifier">const_pointer</span><span class="special">>::</span><span class="identifier">value</span><span class="special">.</span> 117</pre> 118<h6> 119<a name="static_string.ref.boost__static_strings__basic_static_string.compare.overload9.h6"></a> 120 <span class="phrase"><a name="static_string.ref.boost__static_strings__basic_static_string.compare.overload9.return_value"></a></span><a class="link" href="overload9.html#static_string.ref.boost__static_strings__basic_static_string.compare.overload9.return_value">Return 121 Value</a> 122 </h6> 123<p> 124 The result of lexicographically comparing <code class="computeroutput"><span class="identifier">sub1</span></code> 125 and <code class="computeroutput"><span class="identifier">sub2</span></code>. 126 </p> 127<h6> 128<a name="static_string.ref.boost__static_strings__basic_static_string.compare.overload9.h7"></a> 129 <span class="phrase"><a name="static_string.ref.boost__static_strings__basic_static_string.compare.overload9.parameters"></a></span><a class="link" href="overload9.html#static_string.ref.boost__static_strings__basic_static_string.compare.overload9.parameters">Parameters</a> 130 </h6> 131<div class="informaltable"><table class="table"> 132<colgroup> 133<col> 134<col> 135</colgroup> 136<thead><tr> 137<th> 138 <p> 139 Name 140 </p> 141 </th> 142<th> 143 <p> 144 Description 145 </p> 146 </th> 147</tr></thead> 148<tbody> 149<tr> 150<td> 151 <p> 152 <code class="computeroutput"><span class="identifier">pos1</span></code> 153 </p> 154 </td> 155<td> 156 <p> 157 The index at which to begin the substring in the string. 158 </p> 159 </td> 160</tr> 161<tr> 162<td> 163 <p> 164 <code class="computeroutput"><span class="identifier">count1</span></code> 165 </p> 166 </td> 167<td> 168 <p> 169 The length of the substring in the string. 170 </p> 171 </td> 172</tr> 173<tr> 174<td> 175 <p> 176 <code class="computeroutput"><span class="identifier">t</span></code> 177 </p> 178 </td> 179<td> 180 <p> 181 The string to compare. 182 </p> 183 </td> 184</tr> 185<tr> 186<td> 187 <p> 188 <code class="computeroutput"><span class="identifier">pos2</span></code> 189 </p> 190 </td> 191<td> 192 <p> 193 The index at which to begin the substring in the string view. 194 </p> 195 </td> 196</tr> 197<tr> 198<td> 199 <p> 200 <code class="computeroutput"><span class="identifier">count2</span></code> 201 </p> 202 </td> 203<td> 204 <p> 205 The length of the substring in the string view. 206 </p> 207 </td> 208</tr> 209</tbody> 210</table></div> 211</div> 212<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 213<td align="left"></td> 214<td align="right"><div class="copyright-footer">Copyright © 2019, 2020 Krystian Stasiowski<br>Copyright © 2016-2019 Vinnie 215 Falco<p> 216 Distributed under the Boost Software License, Version 1.0. (See accompanying 217 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>) 218 </p> 219</div></td> 220</tr></table> 221<hr> 222<div class="spirit-nav"> 223<a accesskey="p" href="overload8.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../compare.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="../substr.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 224</div> 225</body> 226</html> 227