• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Boost.StaticString</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="next" href="static_string/ref.html" title="Reference">
9</head>
10<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
11<table cellpadding="2" width="100%"><tr>
12<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
13<td align="center"><a href="../../../../index.html">Home</a></td>
14<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
15<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
16<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
17<td align="center"><a href="../../../../more/index.htm">More</a></td>
18</tr></table>
19<hr>
20<div class="spirit-nav"><a accesskey="n" href="static_string/ref.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
21<div class="chapter">
22<div class="titlepage"><div>
23<div><h2 class="title">
24<a name="static_string"></a>Boost.StaticString</h2></div>
25<div><div class="author"><h3 class="author">
26<span class="firstname">Krystian</span> <span class="surname">Stasiowski</span>
27</h3></div></div>
28<div><div class="author"><h3 class="author">
29<span class="firstname">Vinnie</span> <span class="surname">Falco</span>
30</h3></div></div>
31<div><p class="copyright">Copyright © 2019, 2020 Krystian Stasiowski</p></div>
32<div><p class="copyright">Copyright © 2016-2019 Vinnie
33      Falco</p></div>
34<div><div class="legalnotice">
35<a name="static_string.legal"></a><p>
36        Distributed under the Boost Software License, Version 1.0. (See accompanying
37        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>)
38      </p>
39</div></div>
40</div></div>
41<h3>
42<a name="static_string.h0"></a>
43    <span class="phrase"><a name="static_string.introduction"></a></span><a class="link" href="index.html#static_string.introduction">Introduction</a>
44  </h3>
45<p>
46    This library provides a dynamically resizable string of characters with compile-time
47    fixed capacity and contiguous embedded storage in which the characters are placed
48    within the string object itself. Its API closely resembles that of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code>.
49  </p>
50<h3>
51<a name="static_string.h1"></a>
52    <span class="phrase"><a name="static_string.motivation"></a></span><a class="link" href="index.html#static_string.motivation">Motivation</a>
53  </h3>
54<p>
55    A fixed capacity string is useful when:
56  </p>
57<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
58<li class="listitem">
59        Memory allocation is not possible, e.g., embedded environments without a
60        free store, where only a stack and the static memory segment are available.
61      </li>
62<li class="listitem">
63        Memory allocation imposes an unacceptable performance penalty. e.g., with
64        respect to latency.
65      </li>
66<li class="listitem">
67        Allocation of objects with complex lifetimes in the static-memory segment
68        is required.
69      </li>
70<li class="listitem">
71        A dynamically-resizable string is required within <code class="computeroutput"><span class="keyword">constexpr</span></code>
72        functions.
73      </li>
74<li class="listitem">
75        The storage location of the static_vector elements is required to be within
76        the string object itself (e.g. to support <code class="computeroutput"><span class="identifier">memcpy</span></code>
77        for serialization purposes).
78      </li>
79</ul></div>
80<h3>
81<a name="static_string.h2"></a>
82    <span class="phrase"><a name="static_string.requirements"></a></span><a class="link" href="index.html#static_string.requirements">Requirements</a>
83  </h3>
84<p>
85    The library is usable in two different modes: standalone and Boost dependent.
86    This library defaults to Boost dependent mode; standalone mode is opt-in through
87    the use of a configuration macro.
88  </p>
89<p>
90    When in Boost dependent mode, the library requires the use of at least C++11,
91    in addition to Boost.Core, Boost.Utility, and Boost.ContainerHash. In standalone
92    mode, C++17 is required but no libraries except for the standard library are
93    needed.
94  </p>
95<h3>
96<a name="static_string.h3"></a>
97    <span class="phrase"><a name="static_string.design"></a></span><a class="link" href="index.html#static_string.design">Design</a>
98  </h3>
99<p>
100    The over-arching design goal is to resemble the interface and behavior of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code>
101    as much as possible. When any operation would exceed the maximum allowed size
102    of the string, <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">length_error</span></code> is thrown if exceptions are enabled.
103    All algorithms which throw exceptions provide the strong exception safety guarantee.
104    This is intended to be a drop in replacement for <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code>.
105  </p>
106<p>
107    The API of <code class="computeroutput"><span class="identifier">static_string</span></code> only
108    diverges from <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code> in few places, one of which is the addition
109    of the <code class="computeroutput"><span class="identifier">subview</span></code> function, for
110    which this implementation returns a string view instead of <code class="computeroutput"><span class="identifier">static_string</span></code>,
111    and certain functions that will never throw are marked as <code class="computeroutput"><span class="keyword">noexcept</span></code>,
112    which diverges from those of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code>. The
113    available overloads for <code class="computeroutput"><span class="identifier">static_string</span></code>
114    are identical to those of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code>.
115  </p>
116<h3>
117<a name="static_string.h4"></a>
118    <span class="phrase"><a name="static_string.iterators"></a></span><a class="link" href="index.html#static_string.iterators">Iterators</a>
119  </h3>
120<p>
121    The iterator invalidation rules differ from those of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code>:
122  </p>
123<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
124<li class="listitem">
125        Moving a <code class="computeroutput"><span class="identifier">static_string</span></code> invalidates
126        all iterators
127      </li>
128<li class="listitem">
129        Swapping two <code class="computeroutput"><span class="identifier">static_string</span></code>s
130        invalidates all iterators
131      </li>
132</ul></div>
133<h3>
134<a name="static_string.h5"></a>
135    <span class="phrase"><a name="static_string.optimizations"></a></span><a class="link" href="index.html#static_string.optimizations">Optimizations</a>
136  </h3>
137<p>
138    Depending on the character type and size used for a specialization of <code class="computeroutput"><span class="identifier">static_string</span></code>, certain optimizations are used
139    to reduce the size of the class type. Given the name of a specialization of the
140    form <code class="computeroutput"><span class="identifier">basic_static_string</span><span class="special">&lt;</span><span class="identifier">N</span><span class="special">,</span> <span class="identifier">CharT</span><span class="special">,</span> <span class="identifier">Traits</span><span class="special">&gt;</span></code>:
141  </p>
142<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
143<li class="listitem">
144        If <code class="computeroutput"><span class="identifier">N</span></code> is 0, then the class
145        has no non-static data members. Given two objects <code class="computeroutput"><span class="identifier">a</span></code>
146        and <code class="computeroutput"><span class="identifier">b</span></code> of type <code class="computeroutput"><span class="identifier">basic_static_string</span><span class="special">&lt;</span><span class="number">0</span><span class="special">,</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Traits</span><span class="special">&gt;</span></code> and <code class="computeroutput"><span class="identifier">static_string</span><span class="special">&lt;</span><span class="number">0</span><span class="special">,</span>
147        <span class="identifier">U</span><span class="special">,</span> <span class="identifier">Traits</span><span class="special">&gt;</span></code>
148        respectively, the pointer value returned by <code class="computeroutput"><span class="identifier">data</span><span class="special">()</span></code> will be the same if <code class="computeroutput"><span class="identifier">T</span></code>
149        and <code class="computeroutput"><span class="identifier">U</span></code> are the same.
150      </li>
151<li class="listitem">
152        Otherwise, the type of the member used to store the size of the <code class="computeroutput"><span class="identifier">static_string</span></code> will be the smallest standard
153        unsigned integer type that can represent the value <code class="computeroutput"><span class="identifier">N</span></code>.
154      </li>
155</ul></div>
156<h3>
157<a name="static_string.h6"></a>
158    <span class="phrase"><a name="static_string.configuration"></a></span><a class="link" href="index.html#static_string.configuration">Configuration</a>
159  </h3>
160<p>
161    Certain features can be enabled and disabled though defining configuration macros.
162    The macros and the associated feature they control are:
163  </p>
164<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
165        <code class="computeroutput"><span class="identifier">BOOST_STATIC_STRING_STANDALONE</span></code>:
166        When defined, the library is put into standalone mode.
167      </li></ul></div>
168<h3>
169<a name="static_string.h7"></a>
170    <span class="phrase"><a name="static_string.acknowledgments"></a></span><a class="link" href="index.html#static_string.acknowledgments">Acknowledgments</a>
171  </h3>
172<p>
173    Thanks to <a href="https://github.com/K-ballo" target="_top">Agustín Bergé</a>, <a href="https://github.com/pdimov" target="_top">Peter Dimov</a>, <a href="https://github.com/glenfe" target="_top">Glen
174    Fernandes</a>, and <a href="https://github.com/LeonineKing1199" target="_top">Christian
175    Mazakas</a> for their constant feedback and guidance during the development
176    of this library.
177  </p>
178<p>
179    The development of this library is sponsored by <a href="https://cppalliance.org" target="_top">The
180    C++ Alliance</a>.
181  </p>
182<h3>
183<a name="static_string.h8"></a>
184    <span class="phrase"><a name="static_string.reference"></a></span><a class="link" href="index.html#static_string.reference">Reference</a>
185  </h3>
186<p>
187    Defined in namespace <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">static_strings</span></code>:
188  </p>
189<p>
190    <a class="link" href="static_string/ref/boost__static_strings__basic_static_string.html" title="basic_static_string"><code class="computeroutput"><span class="identifier">basic_static_string</span></code></a>
191  </p>
192</div>
193<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
194<td align="left"><p><small>Last revised: August 11, 2020 at 14:59:20 GMT</small></p></td>
195<td align="right"><div class="copyright-footer"></div></td>
196</tr></table>
197<hr>
198<div class="spirit-nav"><a accesskey="n" href="static_string/ref.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
199</body>
200</html>
201