2019-11-07 11:18:14 -05:00
2019-11-06 19:39:03 -05:00
2019-11-07 10:10:30 -05:00
2019-09-13 06:29:15 -07:00
2019-09-13 06:29:15 -07:00
2019-09-13 06:29:15 -07:00
2019-09-13 06:29:15 -07:00
2019-09-13 06:29:15 -07:00
2019-09-13 06:29:15 -07:00
2019-09-13 06:29:15 -07:00
2019-09-13 06:29:15 -07:00
2019-11-06 19:39:22 -05:00
2019-09-13 10:05:39 -07:00
2019-09-13 06:29:15 -07:00

Boost.FixedString

Branch Travis Appveyor Azure Pipelines codecov.io Docs Matrix
master Build Status Build status Build Status codecov Documentation Matrix
develop Build Status Build status Build Status codecov Documentation Matrix

This is currently NOT an official Boost library.

Introduction

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

Motivation

A fixed capacity string is useful when:

  • Memory allocation is not possible, e.g., embedded environments without a free store, where only a stack and the static memory segment are available.
  • Memory allocation imposes an unacceptable performance penalty. e.g., with respect to latency.
  • Allocation of objects with complex lifetimes in the static-memory segment is required.
  • A dynamically-resizable string is required within constexpr functions.
  • The storage location of the static_vector elements is required to be within the string object itself (e.g. to support memcpy for serialization purposes).

Design

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. All algorithms which throw exceptions provide the strong exception safety guarantee. This is intended to be a drop in replacement for std::string. All the operations for fixed_string work when the source is within the string itself.

The API of fixed_string only diverges from std::string in few places, being substr for which this implementation returns a string view instead of fixed_string, and certain functions that will never throw are marked as noexcept, which diverges from those of std::string. Every function that is in the C++20 specification of std::stringis present in this implementation, with the only difference being the lack ofconstexprfor the time being. The avaliable overloads forfixed_stringare identical to those ofstd::string, except for operator+which is explicitly deleted as no reasonable implementation would be possible, due to the difficulty in determining the size of the resultingfixed_string`.

Iterators

The iterator invalidation rules are different than those for std::string, since:

  • Moving a string invalidates all iterators
  • Swapping two strings invalidates all iterators

License

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)

Description
A fixed capacity dynamically sized string
Readme 970 KiB
Languages
C++ 98.4%
CMake 1.1%
Shell 0.4%
HTML 0.1%