Files
static_string/example/static_cstring
Gennaro Prota 62ed5ee17a Fix basic_static_cstring::compare(const CharT*) for over-long inputs
compare(const CharT* s) constructed a temporary basic_static_cstring<N>
from s and delegated to the class-type overload. The constructor throws
std::length_error when traits::length(s) > N, and because compare() is
noexcept, the throw led to std::terminate():

  static_cstring<3> s("abc");
  s.compare("abcd");              // terminate() via noexcept throw

The free operator==() / operator!=() overloads for const CharT*, which
delegate to compare(), had the same flaw.
2026-04-21 16:13:29 +02:00
..

This directory contains an experimental implementation of basic_static_cstring, which differs from basic_static_string in the following ways:

basic_static_cstring basic_static_string
Layout sizeof == N + 1 Has size member
Embedded NULs Not supported Supported
Trivially copyable Yes No

Additionally, when N <= UCHAR_MAX, basic_static_cstring employs an optimization that avoids calling std::strlen() to compute the size.

This work stems from boostorg/static_string#23.

If you believe basic_static_cstring should become part of the public API, please share your feedback on the Boost mailing list.