mirror of
https://github.com/boostorg/static_string.git
synced 2026-08-25 22:33:16 +02:00
The defaulted operators had the wrong semantics, as they compared the
entire data_ buffer. The bug showed up when shrinking:
static_cstring<10> s("hello");
s.assign("hi", 2); // data_[3..4] still "lo"
static_cstring<10> fresh("hi");
assert(s == fresh); // FAILED
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.