Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for a snapshot of the develop branch, built from commit 65eb09a2c6.


Krystian Stasiowski

Vinnie Falco

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at


This library provides a dynamically resizable string of characters with compile-time fixed capacity and contiguous embedded storage in which the characters are placed within the string object itself. Its API closely resembles that of std::string.


A fixed capacity string is useful when:


The library is usable in two different modes: standalone and Boost dependent. This library defaults to Boost dependent mode; standalone mode is opt-in through the use of a configuration macro.

When in Boost dependent mode, the library requires the use of at least C++11, in addition to Boost.Core, Boost.Utility, and Boost.ContainerHash. In standalone mode, C++17 is required but no libraries except for the standard library are needed.


The over-arching design goal is to resemble the interface and behavior of std::string as much as possible. When any operation would exceed the maximum allowed size of the string, std::length_error is thrown if exceptions are enabled. All algorithms which throw exceptions provide the strong exception safety guarantee. This is intended to be a drop in replacement for std::string.

The API of static_string only diverges from std::string in few places, one of which is the addition of the subview function, for which this implementation returns a string view instead of static_string, and certain functions that will never throw are marked as noexcept, which diverges from those of std::string. The available overloads for static_string are identical to those of std::string.


The iterator invalidation rules differ from those of std::string:


Depending on the character type and size used for a specialization of static_string, certain optimizations are used to reduce the size of the class type. Given the name of a specialization of the form basic_static_string<N, CharT, Traits>:


Certain features can be enabled and disabled though defining configuration macros. The macros and the associated feature they control are:


Thanks to Agustín Bergé, Peter Dimov, Glen Fernandes, and Christian Mazakas for their constant feedback and guidance during the development of this library.

The development of this library is sponsored by The C++ Alliance.


Defined in namespace boost::static_strings:


Last revised: May 12, 2021 at 01:36:43 GMT