Skip to content

Commit ccdaf2e

Browse files
committed
Add an experimental basic_static_cstring template in example/
This introduces an alternative to basic_static_string designed for use in POD types: Trivially copyable, having a sizeof == N + 1, with no embedded NULs. Placed in example/ to gather user feedback before committing to a public API. See <#23>.
1 parent 0c5e5b8 commit ccdaf2e

5 files changed

Lines changed: 1179 additions & 0 deletions

File tree

.github/workflows/example.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#
2+
# Copyright (c) 2025 Gennaro Prota (gennaro dot prota at gmail dot com)
3+
#
4+
# Distributed under the Boost Software License, Version 1.0. (See accompanying
5+
# file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
6+
#
7+
# Official repository: https://github.com/boostorg/static_string
8+
#
9+
10+
name: Example (basic_static_cstring)
11+
12+
on:
13+
pull_request:
14+
push:
15+
branches:
16+
- master
17+
- develop
18+
- bugfix/**
19+
- feature/**
20+
- fix/**
21+
- github/**
22+
- pr/**
23+
paths-ignore:
24+
- LICENSE
25+
- meta/**
26+
- README.md
27+
28+
env:
29+
B2_TARGETS: libs/$SELF/example
30+
31+
jobs:
32+
call-boost-ci:
33+
name: Run Boost.CI
34+
uses: boostorg/boost-ci/.github/workflows/reusable.yml@master
35+
with:
36+
exclude_cxxstd: '98,03,0x,11,14,17'
37+
enable_pr_coverage: false
38+
enable_multiarch: false

example/static_cstring/Jamfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Copyright (c) 2025 Gennaro Prota (gennaro dot prota at gmail dot com)
3+
#
4+
# Distributed under the Boost Software License, Version 1.0. (See accompanying
5+
# file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
6+
#
7+
# Official repository: https://github.com/boostorg/static_string
8+
#
9+
10+
import testing ;
11+
12+
project
13+
: requirements
14+
<include>../../include
15+
<warnings>extra
16+
<cxxstd>20
17+
;
18+
19+
run static_cstring_test.cpp ;

example/static_cstring/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
This directory contains an experimental implementation of `basic_static_cstring`, which differs from `basic_static_string` in the following ways:
2+
3+
| | `basic_static_cstring` | `basic_static_string` |
4+
|---------------------|------------------------|-----------------------|
5+
| Layout | `sizeof == N + 1` | Has size member |
6+
| Embedded NULs | Not supported | Supported |
7+
| Trivially copyable | Yes | No |
8+
9+
Additionally, when `N <= UCHAR_MAX`, `basic_static_cstring` employs an optimization that avoids calling `std::strlen()` to compute the size.
10+
11+
This work stems from [boostorg/static_string#23](https://github.com/boostorg/static_string/issues/23).
12+
13+
If you believe `basic_static_cstring` should become part of the public API, please share your feedback on the Boost mailing list.

0 commit comments

Comments
 (0)