Gennaro Prota 9271183ea8 Fix the basic_static_cstring array ctor to respect the no-embedded-NULs invariant
The constructor taking a const CharT (&)[M] copied M - 1 characters
verbatim via assign(arr, M - 1), preserving any embedded NULs in the
input. This would violate the type's documented "no embedded NULs"
invariant.

  const char arr[] = { '1', '2', '\0', '4', '5', '\0' };
  static_cstring<5> s(arr);
  // data_ holds {'1','2','\0','4','5','\0'} --- embedded NUL stored

Delegate to assign(arr) instead, which uses traits::length() to
determine the size. This matches the behavior of the other
CharT-accepting entry points (assign(const CharT*), the const CharT*
constructor) and makes the invariant self-enforcing at construction.

Note: In practice, this is a bug that would never surface, because the
array constructor is never chosen for static_cstring<N> s(arr)---the
pointer constructor always wins---but the array constructor is needed
for CTAD (deduction guide), so it better be correct.

This also means the test we added is, at the moment, superfluous.
2026-04-21 16:14:06 +02:00
2025-10-24 11:57:55 +02:00
2025-10-22 18:35:38 +02:00
2025-12-19 18:26:40 +01:00
2020-04-18 14:09:20 -04:00
2025-10-07 10:19:31 +02:00
2022-10-31 16:09:33 -07:00
2025-10-24 11:57:55 +02:00
2019-09-13 06:29:15 -07:00
2025-10-22 19:11:09 +02:00
2019-09-13 06:29:15 -07:00
2025-10-24 11:58:47 +02:00
2020-03-02 19:29:31 -05:00
2019-09-13 06:29:15 -07:00
2025-10-24 11:59:10 +02:00

Boost.StaticString

Branch GHA CI 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

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.

Documentation

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)

S
Description
A fixed capacity dynamically sized string
Readme
1.4 MiB
Languages
C++ 98.5%
CMake 0.9%
Shell 0.5%
HTML 0.1%