1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>basic_static_string::replace (4 of 14 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="../replace.html" title="basic_static_string::replace"> 9<link rel="prev" href="overload3.html" title="basic_static_string::replace (3 of 14 overloads)"> 10<link rel="next" href="overload5.html" title="basic_static_string::replace (5 of 14 overloads)"> 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="overload3.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../replace.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="overload5.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.replace.overload4"></a><a class="link" href="overload4.html" title="basic_static_string::replace (4 of 14 overloads)">basic_static_string::replace 28 (4 of 14 overloads)</a> 29</h5></div></div></div> 30<p> 31 Replace a part of the string. 32 </p> 33<h6> 34<a name="static_string.ref.boost__static_strings__basic_static_string.replace.overload4.h0"></a> 35 <span class="phrase"><a name="static_string.ref.boost__static_strings__basic_static_string.replace.overload4.synopsis"></a></span><a class="link" href="overload4.html#static_string.ref.boost__static_strings__basic_static_string.replace.overload4.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="identifier">basic_static_string</span><span class="special">&</span> 40<span class="identifier">replace</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">n1</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">n2</span> <span class="special">=</span> <a class="link" href="../npos.html" title="basic_static_string::npos">npos</a><span class="special">);</span> 46</pre> 47<h6> 48<a name="static_string.ref.boost__static_strings__basic_static_string.replace.overload4.h1"></a> 49 <span class="phrase"><a name="static_string.ref.boost__static_strings__basic_static_string.replace.overload4.description"></a></span><a class="link" href="overload4.html#static_string.ref.boost__static_strings__basic_static_string.replace.overload4.description">Description</a> 50 </h6> 51<p> 52 Constructs a temporary <code class="computeroutput"><span class="identifier">string_view_type</span></code> 53 object <code class="computeroutput"><span class="identifier">sv</span></code> from <code class="computeroutput"><span class="identifier">t</span></code>, and replaces <code class="computeroutput"><span class="identifier">rcount</span></code> 54 characters starting at index <code class="computeroutput"><span class="identifier">pos1</span></code> 55 with those of <code class="computeroutput"><span class="identifier">sv</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">n2</span><span class="special">)</span></code>, 56 where <code class="computeroutput"><span class="identifier">rcount</span></code> is std::min(n1, 57 <a class="link" href="../size.html" title="basic_static_string::size"><code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code></a> 58 - pos). 59 </p> 60<h6> 61<a name="static_string.ref.boost__static_strings__basic_static_string.replace.overload4.h2"></a> 62 <span class="phrase"><a name="static_string.ref.boost__static_strings__basic_static_string.replace.overload4.exception_safety"></a></span><a class="link" href="overload4.html#static_string.ref.boost__static_strings__basic_static_string.replace.overload4.exception_safety">Exception 63 Safety</a> 64 </h6> 65<p> 66 Strong guarantee. 67 </p> 68<h6> 69<a name="static_string.ref.boost__static_strings__basic_static_string.replace.overload4.h3"></a> 70 <span class="phrase"><a name="static_string.ref.boost__static_strings__basic_static_string.replace.overload4.remarks"></a></span><a class="link" href="overload4.html#static_string.ref.boost__static_strings__basic_static_string.replace.overload4.remarks">Remarks</a> 71 </h6> 72<p> 73 All references, pointers, or iterators referring to contained elements 74 are invalidated. Any past-the-end iterators are also invalidated. 75 </p> 76<h6> 77<a name="static_string.ref.boost__static_strings__basic_static_string.replace.overload4.h4"></a> 78 <span class="phrase"><a name="static_string.ref.boost__static_strings__basic_static_string.replace.overload4.template_parameters"></a></span><a class="link" href="overload4.html#static_string.ref.boost__static_strings__basic_static_string.replace.overload4.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.replace.overload4.h5"></a> 113 <span class="phrase"><a name="static_string.ref.boost__static_strings__basic_static_string.replace.overload4.constraints"></a></span><a class="link" href="overload4.html#static_string.ref.boost__static_strings__basic_static_string.replace.overload4.constraints">Constraints</a> 114 </h6> 115<p> 116 <code class="computeroutput"><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> 117 <span class="special">&&</span> <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="keyword">const</span> 118 <span class="identifier">CharT</span><span class="special">*>::</span><span class="identifier">value</span></code>. 119 </p> 120<h6> 121<a name="static_string.ref.boost__static_strings__basic_static_string.replace.overload4.h6"></a> 122 <span class="phrase"><a name="static_string.ref.boost__static_strings__basic_static_string.replace.overload4.return_value"></a></span><a class="link" href="overload4.html#static_string.ref.boost__static_strings__basic_static_string.replace.overload4.return_value">Return 123 Value</a> 124 </h6> 125<p> 126 <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> 127 </p> 128<h6> 129<a name="static_string.ref.boost__static_strings__basic_static_string.replace.overload4.h7"></a> 130 <span class="phrase"><a name="static_string.ref.boost__static_strings__basic_static_string.replace.overload4.parameters"></a></span><a class="link" href="overload4.html#static_string.ref.boost__static_strings__basic_static_string.replace.overload4.parameters">Parameters</a> 131 </h6> 132<div class="informaltable"><table class="table"> 133<colgroup> 134<col> 135<col> 136</colgroup> 137<thead><tr> 138<th> 139 <p> 140 Name 141 </p> 142 </th> 143<th> 144 <p> 145 Description 146 </p> 147 </th> 148</tr></thead> 149<tbody> 150<tr> 151<td> 152 <p> 153 <code class="computeroutput"><span class="identifier">pos1</span></code> 154 </p> 155 </td> 156<td> 157 <p> 158 The index to replace at. 159 </p> 160 </td> 161</tr> 162<tr> 163<td> 164 <p> 165 <code class="computeroutput"><span class="identifier">n1</span></code> 166 </p> 167 </td> 168<td> 169 <p> 170 The number of characters to replace. 171 </p> 172 </td> 173</tr> 174<tr> 175<td> 176 <p> 177 <code class="computeroutput"><span class="identifier">t</span></code> 178 </p> 179 </td> 180<td> 181 <p> 182 The object to replace with. 183 </p> 184 </td> 185</tr> 186<tr> 187<td> 188 <p> 189 <code class="computeroutput"><span class="identifier">pos2</span></code> 190 </p> 191 </td> 192<td> 193 <p> 194 The index to begin the substring. 195 </p> 196 </td> 197</tr> 198<tr> 199<td> 200 <p> 201 <code class="computeroutput"><span class="identifier">n2</span></code> 202 </p> 203 </td> 204<td> 205 <p> 206 The length of the substring. The default argument for this 207 parameter is <a class="link" href="../npos.html" title="basic_static_string::npos"><code class="computeroutput"><span class="identifier">npos</span></code></a>. 208 </p> 209 </td> 210</tr> 211</tbody> 212</table></div> 213<h6> 214<a name="static_string.ref.boost__static_strings__basic_static_string.replace.overload4.h8"></a> 215 <span class="phrase"><a name="static_string.ref.boost__static_strings__basic_static_string.replace.overload4.exceptions"></a></span><a class="link" href="overload4.html#static_string.ref.boost__static_strings__basic_static_string.replace.overload4.exceptions">Exceptions</a> 216 </h6> 217<div class="informaltable"><table class="table"> 218<colgroup> 219<col> 220<col> 221</colgroup> 222<thead><tr> 223<th> 224 <p> 225 Type 226 </p> 227 </th> 228<th> 229 <p> 230 Thrown On 231 </p> 232 </th> 233</tr></thead> 234<tbody> 235<tr> 236<td> 237 <p> 238 <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">length_error</span></code> 239 </p> 240 </td> 241<td> 242 <p> 243 <a class="link" href="../size.html" title="basic_static_string::size"><code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code></a> 244 + (std::min(n2, sv.size()) - rcount) > <a class="link" href="../max_size.html" title="basic_static_string::max_size"><code class="computeroutput"><span class="identifier">max_size</span><span class="special">()</span></code></a> 245 </p> 246 </td> 247</tr> 248<tr> 249<td> 250 <p> 251 <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">out_of_range</span></code> 252 </p> 253 </td> 254<td> 255 <p> 256 pos1 > <a class="link" href="../size.html" title="basic_static_string::size"><code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code></a> 257 </p> 258 </td> 259</tr> 260<tr> 261<td> 262 <p> 263 <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">out_of_range</span></code> 264 </p> 265 </td> 266<td> 267 <p> 268 <code class="computeroutput"><span class="identifier">pos2</span> <span class="special">></span> 269 <span class="identifier">sv</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code> 270 </p> 271 </td> 272</tr> 273</tbody> 274</table></div> 275</div> 276<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 277<td align="left"></td> 278<td align="right"><div class="copyright-footer">Copyright © 2019, 2020 Krystian Stasiowski<br>Copyright © 2016-2019 Vinnie 279 Falco<p> 280 Distributed under the Boost Software License, Version 1.0. (See accompanying 281 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>) 282 </p> 283</div></td> 284</tr></table> 285<hr> 286<div class="spirit-nav"> 287<a accesskey="p" href="overload3.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../replace.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="overload5.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 288</div> 289</body> 290</html> 291