# Types

> StringZilla for C++

The C++ layer lives in `namespace ashvardanian::stringzilla`, conventionally aliased as `sz`, and is built on the types below plus a 256-bit `byteset`.

- `sz::string_slice<char_type>` — a non-owning, length-bounded view over `char` or `char const`.
  Two aliases exist: the read-only `sz::string_view_t = string_slice<char const>` and the mutable `sz::string_span_t = string_slice<char>`.
- `sz::string<allocator = std::allocator<char>>` — an owning, Small-String-Optimized `char` container; the alias `sz::string_t` uses the default `std::allocator`.
  A stateful allocator travels with the string under the usual `std::allocator_traits` propagation rules, and an empty one costs no bytes.
- `sz::strings_view_t` — a borrowed column of strings, wrapping a `sz_strings_view_t` in any of its layouts.
- `sz::strings<allocator = sz::heap_alloc<char>>` — an owned, move-only column, a `sz_strings_span_t` tape and the allocator of its blocks; the alias `sz::strings_t` uses the default.
- `sz::byteset_t` — the C++ wrapper around `sz_byteset_t`, constructible from an initializer list, a `(pointer, count)` pair, or a `std::array`, and composable with `operator|`.
- `sz::status_t` — a scoped enum mirroring `sz_status_t` with `success_k`, `bad_alloc_k`, `invalid_utf8_k`, `contains_duplicates_k`, and the rest, returned by the fallible free functions and the string's allocating verbs.

`sz::string_view_t` is implicitly constructible from a `char const *`, a `(pointer, length)` pair, `std::string`, and `std::string_view`, and converts back to both; `sz::string_t` adds construction from repeats, sub-ranges, initializer lists, and lazy `sz::concatenate(...)` expressions.
Both satisfy the `std::string`/`std::string_view` member surface — `data`, `size`, `length`, `empty`, `at`, `front`, `back`, iterators, `substr`, `compare`, the relational operators, and on C++20 `operator<=>` — so they are drop-in for most code.
Both also stream through `operator<<`, and `std::hash<sz::string_t>` / `std::hash<sz::string_view_t>` specializations are provided so they work as unordered-container keys out of the box.

User-defined literals live in `sz::literals`:

```cpp
using namespace sz::literals;
sz::string_view_t v = "needle"_sv;   // a view, no allocation
sz::byteset_t s = " \t\n\r"_bs;      // a byte-set from a literal
```

Convenience byte-sets are available as free functions: `sz::whitespaces_set()`, `sz::newlines_set()`, `sz::digits_set()`, `sz::hexdigits_set()`, `sz::octdigits_set()`, and `sz::ascii_letters_set()`.

`#include <stringzilla/stringzilla.hpp>`

`#include <stringzilla/types.hpp>`

## byteset_t

A set of characters represented as a bitset with 256 slots.

```cpp
class byteset_t
```

## string_view_for

Extracts the view type of a string-like type: the nested `string_view_t` typedef of StringZilla types, or the type itself for STL types like `std::string_view`.

```cpp
template <typename string_type_>
struct string_view_for
```

## reversed_iterator_for

A reverse iterator for mutable and immutable character buffers.

```cpp
template <typename value_type_>
class reversed_iterator_for
```

Replaces `std::reverse_iterator` to avoid including `<iterator>`.

## concatenation_operand

Infers how an operand is stored inside a [`concatenation`](#concatenation) expression.

```cpp
template <typename type_>
struct concatenation_operand
```

The [`concatenate`](#concatenate) function and `operator|` take forwarding references, so an lvalue `sz::string_t` deduces to `sz::string_t &` and a literal deduces to `char const (&)[N]`. Neither exposes the `value_type`, `size()` and `copy()` interface the expression template relies on, which is why baking the deduced type straight into [`concatenation`](#concatenation) fails to compile. Everything that is not already a nested expression is therefore normalized into a `string_view_t`, matching what the `[string_slice::operator|](#operator|)` overloads produce.

## concatenation

An "expression template" for lazy concatenation of strings using the `operator|`.

```cpp
template <typename first_type_,
          typename second_type_>
struct concatenation
```

- `first` `first_type_`
- `second` `second_type_`

See also: [https://en.wikipedia.org/wiki/Expression_templates](https://en.wikipedia.org/wiki/Expression_templates)

See also: [concatenate](#concatenate) function for usage examples.

## concatenation_result

SFINAE-type used to infer the resulting type of concatenating multiple string together.

```cpp
template <typename... args_types_>
struct concatenation_result
```

## status_t

Why a call failed, in the vocabulary the C ABI and every binding share.

```cpp
enum status_t
```

Every enumerator takes its value from `[sz_status_t](https://www.unum.cloud/docs/stringzilla/c/types.md#sz_status_t)` in `types.h`, so the C++ mirror and the ABI cannot drift, and the crossing is a cast rather than a table.

Statuses fall into four categories, with no interruptions to report. Resources: [`bad_alloc_k`](#bad_alloc_k), [`missing_gpu_k`](#missing_gpu_k), [`device_code_mismatch_k`](#device_code_mismatch_k), [`missing_kernel_k`](#missing_kernel_k) and [`missing_library_k`](#missing_library_k). Input: [`invalid_utf8_k`](#invalid_utf8_k), [`contains_duplicates_k`](#contains_duplicates_k), [`unexpected_dimensions_k`](#unexpected_dimensions_k), [`device_memory_mismatch_k`](#device_memory_mismatch_k) and [`authentication_failed_k`](#authentication_failed_k). State: [`overflow_risk_k`](#overflow_risk_k). Defects: [`unknown_k`](#unknown_k). Any verb that allocates, binds a device or touches a file may also return a Resources status. A verb's own block lists only what its contract adds.

- `success_k` = `sz_success_k`: Finished without error.
- `bad_alloc_k` = `sz_bad_alloc_k`: An allocation failed.
- `invalid_utf8_k` = `sz_invalid_utf8_k`: The input is not valid UTF-8.
- `contains_duplicates_k` = `sz_contains_duplicates_k`: A collection that must hold unique elements holds duplicates.
- `overflow_risk_k` = `sz_overflow_risk_k`: The input is too large for the counters or the offsets holding it.
- `unexpected_dimensions_k` = `sz_unexpected_dimensions_k`: Operand sizes contradict each other, like an output span shorter than the input.
- `missing_gpu_k` = `sz_missing_gpu_k`: No GPU of the vendor this build targets answers.
- `device_code_mismatch_k` = `sz_device_code_mismatch_k`: The device code lacks the kernel, or it failed to build, launch or finish.
- `device_memory_mismatch_k` = `sz_device_memory_mismatch_k`: An operand lies in memory the device cannot address.
- `authentication_failed_k` = `sz_authentication_failed_k`: An authenticated decryption saw a tag that does not match its ciphertext.
- `missing_kernel_k` = `sz_missing_kernel_k`: No capability in the capability mask has this kernel.
- `missing_library_k` = `sz_missing_library_k`: A dispatch point or finder called from a header-only build, which links no library.
- `unknown_k` = `sz_status_unknown_k`: A failure no other status describes.

## expected

A result paired with the `[status_t](#status_t)` explaining it; the value is only meaningful on [`success_k`](#success_k).

```cpp
template <typename value_type_>
struct expected
```

- `value` `value_type_`
- `status` `status_t`

## indexed_container_iterator

Random access iterator for any immutable container with indexed element lookup support.

```cpp
template <typename container_type_>
struct indexed_container_iterator
```

Notes: Designed for `[strings_view_t](#strings_view_t)` and [`strings`](#strings) compatibility with STL algorithms and ranges.

## head_body_tail_t

Helper structure for dividing a range of data into three parts: head, body, and tail, generally used to minimize misaligned (split) stores and operate on aligned pages.

```cpp
struct head_body_tail_t
```

- `head` `std::size_t`
- `body` `std::size_t`
- `tail` `std::size_t`

## vector

Safer alternative to [`std::vector`](#vector), that avoids exceptions and copy constructors: every member that allocates returns a `[status_t](#status_t)` instead of throwing.

```cpp
template <typename value_type_,
          typename allocator_type_ = heap_alloc<value_type_>>
class vector
```

## string

Memory-owning string class with a Small String Optimization.

```cpp
template <typename allocator_type_ = std::allocator<char>>
class string
```

#### API

Some APIs are different from `[string_slice](#string_slice):`

- [`lstrip`](#lstrip), [`rstrip`](#rstrip), [`strip`](#strip) modify the string in-place, instead of returning a new view.
- [`sat`](#sat), [`sub`](#sub), and element access have non-const overloads returning mutable references.
Functions defined for [`string`](#string), but not present in `[string_slice](#string_slice):`

- [`replace`](#replace), [`insert`](#insert), [`erase`](#erase), [`append`](#append), [`push_back`](#push_back), [`pop_back`](#pop_back), [`resize`](#resize),
- [`insert_at`](#insert_at), [`replace_slice`](#replace_slice) and [`erase_slice`](#erase_slice) twins over signed offsets,
- [`replace_all`](#replace_all) and `erase_all` similar to Boost,
- `translate` for character mapping,
- [`fill_random`](https://www.unum.cloud/docs/stringzilla/cpp/sorting-and-sets.md#fill_random) for fast random string generation.
Functions defined for `[string_slice](#string_slice)`, but not present in `string:`

- [`partition`](#partition), [`rpartition`](#rpartition), [`split`](https://www.unum.cloud/docs/stringzilla/cpp/splitting-and-partitioning.md#split), [`rsplit`](https://www.unum.cloud/docs/stringzilla/cpp/splitting-and-partitioning.md#rsplit), [`find_all`](https://www.unum.cloud/docs/stringzilla/cpp/searching-and-counting.md#find_all) and [`rfind_all`](https://www.unum.cloud/docs/stringzilla/cpp/searching-and-counting.md#rfind_all), left out to enforce lifetimes over long operations,
- [`remove_prefix`](#remove_prefix) and [`remove_suffix`](#remove_suffix).

#### Errors

Nothing throws. The default constructor is `constexpr`, and moves are `noexcept`. Copies and conversions go through [`copy`](#copy), [`make`](https://www.unum.cloud/docs/stringzilla/cpp/runtime-dispatch.md#make) and [`assign`](#assign), and every allocating verb returns a `[status_t](#status_t)`, or an [`expected`](#expected) beside an iterator. Positions past the end clamp to it, like Python's slices, and [`at`](#at) checks its position with a debug assertion only.

## npos

Special value for missing matches.

```cpp
size_type npos;
```

We take the largest 63-bit unsigned integer on 64-bit machines. We take the largest 31-bit unsigned integer on 32-bit machines.

## min_capacity

The number of characters that can be stored in the internal buffer.

```cpp
size_type min_capacity;
```

Depends on the size of the internal buffer for the "Small String Optimization".

## string

Copies go through [copy](#copy) and [assign](#assign), which report a failed allocation.

```cpp
constexpr string() noexcept;
```

```cpp
constexpr string(allocator_type_ const & allocator) noexcept;
```

```cpp
string(string && other) noexcept;
```

```cpp
string(string const &)=delete;
```

Copies go through [copy](#copy) and [assign](#assign), which report a failed allocation.

```cpp
string(std::nullptr_t)=delete;
```

## *

```cpp
~string() noexcept;
```

- `~string`
- `~strings`

## operator=

Steals the buffer, so the allocators must propagate on move or always compare equal; any other pair copies through [assign](#assign), which reports a failed allocation.

```cpp
requires (allocator_traits_t::propagate_on_container_move_assignment::value || allocator_traits_t::is_always_equal::value)
string & operator=(string && other) noexcept;
```

```cpp
string & operator=(string const &)=delete;
```

## copy

A copy of this string, in memory of the allocator that `select_on_container_copy_construction` picks.

```cpp
expected<string> copy() const noexcept;
```

```cpp
size_type copy(value_type *destination) const noexcept;
```

Exports this entire view.

```cpp
size_type copy(
    value_type *destination,
    size_type count,
    size_type skip = 0) const noexcept;
```

Exports at most [`count`](https://www.unum.cloud/docs/stringzilla/cpp/runtime-dispatch.md#count) bytes after the first `skip`, and none at all when `skip` passes the end of the string.

Not an STL function, but useful for concatenations. The STL variant expects at least two arguments.

## swap

Exchanges the string contents witt the `other` string.

```cpp
void swap(string & other) noexcept;
```

## operator[]

Equivalent to Python's `"abc"[-3:-1]`.

```cpp
reference operator[](size_type pos) noexcept;
```

```cpp
const_reference operator[](size_type pos) const noexcept;
```

```cpp
string_view_t operator[](
    std::initializer_list<difference_type> offsets) const noexcept;
```

Equivalent to Python's `"abc"[-3:-1]`.

```cpp
string_span_t operator[](
    std::initializer_list<difference_type> offsets) noexcept;
```

Exception-safe, unlike STL's [`substr`](#substr). Supports signed and unsigned intervals.

## front

The opposite operation to [`remove_prefix`](#remove_prefix), that does no bounds checking.

```cpp
reference front() noexcept;
```

```cpp
const_reference front() const noexcept;
```

```cpp
string_view_t front(difference_type n) const noexcept;
```

The opposite operation to [`remove_prefix`](#remove_prefix), that does no bounds checking.

```cpp
string_span_t front(difference_type n) noexcept;
```

Warnings: The behavior is __undefined__ if `n > size()`.

## back

The opposite operation to [`remove_prefix`](#remove_prefix), that does no bounds checking.

```cpp
reference back() noexcept;
```

```cpp
const_reference back() const noexcept;
```

```cpp
string_view_t back(difference_type n) const noexcept;
```

The opposite operation to [`remove_prefix`](#remove_prefix), that does no bounds checking.

```cpp
string_span_t back(difference_type n) noexcept;
```

Warnings: The behavior is __undefined__ if `n > size()`.

## at

Element access checked by a debug assertion, as `operator`[] is unchecked.

```cpp
reference at(size_type pos) noexcept;
```

```cpp
const_reference at(size_type pos) const noexcept;
```

## sat

Signed alternative to `at()`.

```cpp
value_type sat(difference_type offset) const noexcept;
```

```cpp
reference sat(difference_type offset) noexcept;
```

Handy if you often write `str[str.size() - 2]`.

Warnings: The behavior is __undefined__ if the position is beyond bounds.

## sub

Equivalent to Python's `"abc"[-3:-1]`.

```cpp
string_view_t sub(
    difference_type start,
    difference_type end = npos) const noexcept;
```

```cpp
string_span_t sub(
    difference_type start,
    difference_type end = npos) noexcept;
```

Exception-safe, unlike STL's [`substr`](#substr). Supports signed and unsigned intervals. __Doesn't__ copy or allocate memory!

## remove_prefix

Removes the first `n` characters from the view.

```cpp
void remove_prefix(size_type n) noexcept;
```

Warnings: The behavior is __undefined__ if `n > size()`.

## remove_suffix

Removes the last `n` characters from the view.

```cpp
void remove_suffix(size_type n) noexcept;
```

Warnings: The behavior is __undefined__ if `n > size()`.

## compare

Compares two strings lexicographically.

```cpp
int compare(string_view_t other) const noexcept;
```

```cpp
int compare(
    size_type pos1,
    size_type count1,
    string_view_t other) const noexcept;
```

Compares up to `count1` bytes at `pos1` with `other`, lexicographically, then by length on a common prefix.

```cpp
int compare(
    size_type pos1,
    size_type count1,
    string_view_t other,
    size_type pos2,
    size_type count2) const noexcept;
```

Compares up to `count1` bytes at `pos1` with up to `count2` bytes at `pos2` of `other`, lexicographically, then by length on a common prefix.

```cpp
int compare(const_pointer other) const noexcept;
```

```cpp
int compare(
    size_type pos1,
    size_type count1,
    const_pointer other) const noexcept;
```

Compares up to `count1` bytes at `pos1` with `other`, lexicographically, then by length on a common prefix.

```cpp
int compare(
    size_type pos1,
    size_type count1,
    const_pointer other,
    size_type count2) const noexcept;
```

Compares up to `count1` bytes at `pos1` with the first `count2` bytes of `other`, lexicographically, then by length on a common prefix.

If prefix matches, lengths are compared.

Notes: A `pos1` past the end compares an empty slice.

Notes: A position past the end compares an empty slice.

## operator==

Checks if the string is equal to the other string.

```cpp
bool operator==(string const & other) const noexcept;
```

```cpp
bool operator==(string_view_t other) const noexcept;
```

```cpp
bool operator==(const_pointer other) const noexcept;
```

## operator<=>

Computes the lexicographic ordering between this and the `other` string.

```cpp
std::strong_ordering operator<=>(string const & other) const noexcept;
```

```cpp
std::strong_ordering operator<=>(string_view_t other) const noexcept;
```

```cpp
std::strong_ordering operator<=>(const_pointer other) const noexcept;
```

## starts_with

Checks if the string starts with the other string.

```cpp
bool starts_with(string_view_t other) const noexcept;
```

```cpp
bool starts_with(const_pointer other) const noexcept;
```

```cpp
bool starts_with(value_type other) const noexcept;
```

Checks if the string starts with the other character.

## ends_with

Checks if the string ends with the other string.

```cpp
bool ends_with(string_view_t other) const noexcept;
```

```cpp
bool ends_with(const_pointer other) const noexcept;
```

```cpp
bool ends_with(value_type other) const noexcept;
```

Checks if the string ends with the other character.

## contains

Checks if the string contains the given substring.

```cpp
bool contains(string_view_t other) const noexcept;
```

```cpp
bool contains(value_type character) const noexcept;
```

```cpp
bool contains(const_pointer other) const noexcept;
```

Checks if the string contains the given null-terminated substring.

## find

Find the first occurrence of a substring, skipping the first `skip` characters.

```cpp
size_type find(string_view_t other, size_type skip = 0) const noexcept;
```

```cpp
size_type find(value_type character, size_type skip = 0) const noexcept;
```

Find the first occurrence of a character, skipping the first `skip` characters.

```cpp
size_type find(
    const_pointer other,
    size_type pos,
    size_type count) const noexcept;
```

```cpp
size_type find(byteset_t set) const noexcept;
```

Find the first occurrence of a character from a set.

Returns: For an __empty__ `other`, `skip`.

Returns: [`npos`](#npos) if `skip > size()`.

Returns: For an __empty__ `other`, `pos`; delegates to the `string_view_t` overload.

Returns: [`npos`](#npos) if `pos > size()`.

## rfind

Find the last occurrence of a substring.

```cpp
size_type rfind(string_view_t other) const noexcept;
```

```cpp
size_type rfind(string_view_t other, size_type until) const noexcept;
```

Find the last occurrence of a substring, within first `until` characters.

```cpp
size_type rfind(value_type character) const noexcept;
```

Find the last occurrence of a character.

```cpp
size_type rfind(value_type character, size_type until) const noexcept;
```

Find the last occurrence of a character, within first `until` characters.

```cpp
size_type rfind(
    const_pointer other,
    size_type until,
    size_type count) const noexcept;
```

Find the last occurrence of a substring, within first `until` characters.

```cpp
size_type rfind(byteset_t set) const noexcept;
```

Find the last occurrence of a character from a set.

Returns: `size()` for an __empty__ `other`, matching [`std::string_view::rfind`](#rfind).

Returns: For an __empty__ `other`, `min(until, size())`, matching [`std::string_view::rfind`](#rfind).

Returns: For an __empty__ `other`, `min(until, size())`; consistent with the `string_view_t` overload above.

## find_first_of

Find the first occurrence of a character from a `set`.

```cpp
size_type find_first_of(
    byteset_t set,
    size_type skip = 0) const noexcept;
```

```cpp
size_type find_first_of(
    string_view_t other,
    size_type skip = 0) const noexcept;
```

Find the first occurrence of a character from the `other` string.

```cpp
size_type find_first_of(
    const_pointer other,
    size_type skip,
    size_type count) const noexcept;
```

Find the first occurrence of a character from a set.

- `set` (in): The characters to match.
- `skip` (in): Number of characters to skip before the search.
- `other` (in): The characters to match.
- `count` (in): Number of characters at `other`.

## find_first_not_of

Find the first occurrence of a character outside a `set`.

```cpp
size_type find_first_not_of(
    byteset_t set,
    size_type skip = 0) const noexcept;
```

```cpp
size_type find_first_not_of(
    string_view_t other,
    size_type skip = 0) const noexcept;
```

Find the first occurrence of a character outside the `other` string.

```cpp
size_type find_first_not_of(
    const_pointer other,
    size_type skip,
    size_type count) const noexcept;
```

Find the first occurrence of a character outside a set.

- `set` (in): The characters to avoid.
- `skip` (in): The number of first characters to be skipped.
- `other` (in): The characters to avoid.
- `count` (in): Number of characters at `other`.

## find_last_of

Find the last occurrence of a character from a `set`.

```cpp
size_type find_last_of(byteset_t set) const noexcept;
```

```cpp
size_type find_last_of(byteset_t set, size_type until) const noexcept;
```

```cpp
size_type find_last_of(
    string_view_t other,
    size_type until = npos) const noexcept;
```

Find the last occurrence of a character from the `other` string.

```cpp
size_type find_last_of(
    const_pointer other,
    size_type until,
    size_type count) const noexcept;
```

Find the last occurrence of a character from a set.

- `until` (in): The offset of the last character to be considered.
- `other` (in): The characters to match.
- `count` (in): Number of characters at `other`.

## find_last_not_of

Find the last occurrence of a character outside a `set`.

```cpp
size_type find_last_not_of(byteset_t set) const noexcept;
```

```cpp
size_type find_last_not_of(
    byteset_t set,
    size_type until) const noexcept;
```

```cpp
size_type find_last_not_of(
    string_view_t other,
    size_type until = npos) const noexcept;
```

Find the last occurrence of a character outside the `other` string.

```cpp
size_type find_last_not_of(
    const_pointer other,
    size_type until,
    size_type count) const noexcept;
```

Find the last occurrence of a character outside a set.

- `until` (in): The offset of the last character to be considered.
- `other` (in): The characters to avoid.
- `count` (in): Number of characters at `other`.

## *

Python-like convenience function, dropping prefix formed of given characters.

```cpp
string & lstrip(byteset_t set) noexcept;
```

Notes: Similar to `boost::algorithm::trim_left_if(str, is_any_of(set))`.

## *

Python-like convenience function, dropping suffix formed of given characters.

```cpp
string & rstrip(byteset_t set) noexcept;
```

Notes: Similar to `boost::algorithm::trim_right_if(str, is_any_of(set))`.

## *

Python-like convenience function, stripping characters from the `set` off both ends.

```cpp
string & strip(byteset_t set) noexcept;
```

Notes: Similar to `boost::algorithm::trim_if(str, is_any_of(set))`.

## resize

Resizes the string to a specified number of characters, padding with the specified character if needed.

```cpp
status_t resize(size_type count, value_type character = '\0') noexcept;
```

- `count` (in): The new size of the string.
- `character` (in): The character to fill new elements with, if expanding, by default the null character.

Statuses: - [`overflow_risk_k`](#overflow_risk_k) A [`count`](https://www.unum.cloud/docs/stringzilla/cpp/runtime-dispatch.md#count) past `max_size`.

## shrink_to_fit

Reduces memory usage by freeing unused memory.

```cpp
status_t shrink_to_fit() noexcept;
```

## reserve

Reserves enough space for a specified number of characters.

```cpp
status_t reserve(size_type capacity) noexcept;
```

- `capacity` (in): The new capacity to reserve.

Statuses: - [`overflow_risk_k`](#overflow_risk_k) A `capacity` past `max_size`.

## assign

Assigns a new value to the string, replacing its current contents.

```cpp
status_t assign(string_view_t other) noexcept;
```

```cpp
template <typename first_type_, typename second_type_>
status_t assign(
    concatenation<first_type_, second_type_> const & other) noexcept;
```

Assigns a concatenated sequence to the string, replacing its current contents.

```cpp
status_t assign(size_type repeats, char_type character) noexcept;
```

Overwrites the string with `character` repeated `repeats` times.

```cpp
status_t assign(const_pointer other, size_type length) noexcept;
```

Overwrites the string with `length` characters from `other`.

```cpp
status_t assign(
    string_view_t str,
    size_type pos,
    size_type count = npos) noexcept;
```

Overwrites the string with at most [`count`](https://www.unum.cloud/docs/stringzilla/cpp/runtime-dispatch.md#count) characters of `str` after its first `pos`, clamping `pos` to its end.

```cpp
template <typename input_iterator>
status_t assign(input_iterator first, input_iterator last) noexcept;
```

Overwrites the string with the characters between `first` and `last`.

```cpp
status_t assign(std::initializer_list<char_type> list) noexcept;
```

Overwrites the string with the characters of `list`.

- `other` (in): The string view whose contents to assign.

Statuses: - [`overflow_risk_k`](#overflow_risk_k) Past `max_size`.

## push_back

Adds a single character to the end of the string.

```cpp
status_t push_back(char_type c) noexcept;
```

- `c` (in): The character to add.

## append

Appends a given character array to the string.

```cpp
status_t append(const_pointer str, size_type length) noexcept;
```

```cpp
status_t append(string_view_t str) noexcept;
```

Appends a string view to the string.

```cpp
status_t append(
    string_view_t str,
    size_type pos,
    size_type length = npos) noexcept;
```

Appends at most `length` characters of `str` after its first `pos`, clamping `pos` to its end.

```cpp
status_t append(const_pointer str) noexcept;
```

Appends the null-terminated `str`.

```cpp
status_t append(size_type repeats, char_type character) noexcept;
```

Appends `character` repeated `repeats` times.

```cpp
status_t append(std::initializer_list<char_type> other) noexcept;
```

Appends the characters of `other`.

```cpp
template <typename input_iterator>
status_t append(input_iterator first, input_iterator last) noexcept;
```

Appends the characters between `first` and `last`.

- `str` (in): The pointer to the array of characters to append.
- `length` (in): The number of characters to append.

Statuses: - [`overflow_risk_k`](#overflow_risk_k) Past `max_size`.

## erase_slice

Erases ____(in-place) the characters between two signed offsets, counted from the end when negative, like Python's `del text[start:end]`.

```cpp
size_type erase_slice(
    difference_type signed_start_offset = 0,
    difference_type signed_end_offset = npos) noexcept;
```

## insert_at

Inserts ____(in-place) [`string`](#string) at a signed offset, counted from the end when negative, like Python's `text[offset:offset] = [string](#string)`.

```cpp
status_t insert_at(
    difference_type signed_offset,
    string_view_t string) noexcept;
```

Statuses: - [`overflow_risk_k`](#overflow_risk_k) Past `max_size`.

## replace_slice

Replaces ____(in-place) the characters between two signed offsets, counted from the end when negative, like Python's `text[start:end] = replacement`.

```cpp
status_t replace_slice(
    difference_type signed_start_offset,
    difference_type signed_end_offset,
    string_view_t replacement) noexcept;
```

Statuses: - [`overflow_risk_k`](#overflow_risk_k) Past `max_size`.

## resize_and_overwrite

Resizes the string to a specified number of characters without initializing new elements, calling the provided callback to overwrite the resized contents.

```cpp
template <typename operation_type_>
status_t resize_and_overwrite(
    size_type count,
    operation_type_ operation) noexcept;
```

- `count` (in): The new size of the string.
- `operation` (in): A callback that receives a pointer and the new size, and returns the actual new size.

See also: [https://en.cppreference.com/w/cpp/string/string/resize_and_overwrite](https://en.cppreference.com/w/cpp/string/string/resize_and_overwrite)

Statuses: - [`overflow_risk_k`](#overflow_risk_k) A [`count`](https://www.unum.cloud/docs/stringzilla/cpp/runtime-dispatch.md#count) past `max_size`.

## clear

Clears the string contents, but __no__ deallocations happen.

```cpp
void clear() noexcept;
```

## erase

Erases ( __in-place__ ) the given range of characters.

```cpp
iterator erase(const_iterator first, const_iterator last) noexcept;
```

```cpp
iterator erase(const_iterator pos) noexcept;
```

Erases ____(in-place) the one character at a given position.

```cpp
string & erase(size_type pos = 0, size_type count = npos) noexcept;
```

Erases ____(in-place) at most [`count`](https://www.unum.cloud/docs/stringzilla/cpp/runtime-dispatch.md#count) characters from `pos`, none when `pos` passes the end.

## insert

Inserts ____(in-place) `character` `repeats` times at `offset`, clamped to the end.

```cpp
status_t insert(
    size_type offset,
    size_type repeats,
    char_type character) noexcept;
```

```cpp
status_t insert(size_type offset, string_view_t other) noexcept;
```

Inserts ____(in-place) `other` at `offset`, clamped to the end.

```cpp
status_t insert(
    size_type offset,
    const_pointer start,
    size_type length) noexcept;
```

Inserts ____(in-place) `length` characters from `start` at `offset`, clamped to the end.

```cpp
status_t insert(
    size_type offset,
    string_view_t other,
    size_type other_index,
    size_type count = npos) noexcept;
```

Inserts ____(in-place) at most [`count`](https://www.unum.cloud/docs/stringzilla/cpp/runtime-dispatch.md#count) characters of `other` after its first `other_index` at `offset`, clamping both positions to their ends.

```cpp
expected<iterator> insert(
    const_iterator it,
    char_type character) noexcept;
```

Inserts ____(in-place) `character` before `it`.

```cpp
expected<iterator> insert(
    const_iterator it,
    size_type repeats,
    char_type character) noexcept;
```

Inserts ____(in-place) `character` `repeats` times before `it`.

```cpp
template <typename input_iterator>
expected<iterator> insert(
    const_iterator it,
    input_iterator first,
    input_iterator last) noexcept;
```

Inserts ____(in-place) the characters between `first` and `last` before `it`.

```cpp
expected<iterator> insert(
    const_iterator it,
    std::initializer_list<char_type> list) noexcept;
```

Inserts ____(in-place) the characters of `list` before `it`.

Statuses: - [`overflow_risk_k`](#overflow_risk_k) Past `max_size`.

## replace

Replaces ____(in-place) at most [`count`](https://www.unum.cloud/docs/stringzilla/cpp/runtime-dispatch.md#count) characters from `pos` with `str`, clamping `pos` to the end, where the replacement appends.

```cpp
status_t replace(
    size_type pos,
    size_type count,
    string_view_t const & str) noexcept;
```

```cpp
status_t replace(
    const_iterator first,
    const_iterator last,
    string_view_t const & str) noexcept;
```

Replaces ____(in-place) the characters between `first` and `last` with `str`.

```cpp
status_t replace(
    size_type pos,
    size_type count,
    string_view_t const & str,
    size_type pos2,
    size_type count2 = npos) noexcept;
```

Replaces ____(in-place) at most [`count`](https://www.unum.cloud/docs/stringzilla/cpp/runtime-dispatch.md#count) characters from `pos` with at most `count2` characters of `str` after its first `pos2`, clamping every position to its end.

```cpp
status_t replace(
    size_type pos,
    size_type count,
    const_pointer cstr,
    size_type count2) noexcept;
```

Replaces ____(in-place) at most [`count`](https://www.unum.cloud/docs/stringzilla/cpp/runtime-dispatch.md#count) characters from `pos` with `count2` characters from `cstr`.

```cpp
status_t replace(
    const_iterator first,
    const_iterator last,
    const_pointer cstr,
    size_type count2) noexcept;
```

Replaces ____(in-place) the characters between `first` and `last` with `count2` characters from `cstr`.

```cpp
status_t replace(
    size_type pos,
    size_type count,
    const_pointer cstr) noexcept;
```

Replaces ____(in-place) at most [`count`](https://www.unum.cloud/docs/stringzilla/cpp/runtime-dispatch.md#count) characters from `pos` with the null-terminated `cstr`.

```cpp
status_t replace(
    const_iterator first,
    const_iterator last,
    const_pointer cstr) noexcept;
```

Replaces ____(in-place) the characters between `first` and `last` with the null-terminated `cstr`.

```cpp
status_t replace(
    size_type pos,
    size_type count,
    size_type count2,
    char_type character) noexcept;
```

Replaces ____(in-place) at most [`count`](https://www.unum.cloud/docs/stringzilla/cpp/runtime-dispatch.md#count) characters from `pos` with `character` repeated `count2` times, clamping `pos` to the end.

```cpp
status_t replace(
    const_iterator first,
    const_iterator last,
    size_type count2,
    char_type character) noexcept;
```

Replaces ____(in-place) the characters between `first` and `last` with `character` repeated `count2` times.

```cpp
template <typename input_iterator>
status_t replace(
    const_iterator first,
    const_iterator last,
    input_iterator first2,
    input_iterator last2) noexcept;
```

Replaces ____(in-place) the characters between `first` and `last` with those between `first2` and `last2`.

```cpp
status_t replace(
    const_iterator first,
    const_iterator last,
    std::initializer_list<char_type> list) noexcept;
```

Replaces ____(in-place) the characters between `first` and `last` with those of `list`.

Statuses: - [`overflow_risk_k`](#overflow_risk_k) Past `max_size`.

## pop_back

Removes the last character from the string.

```cpp
void pop_back() noexcept;
```

Warnings: The behavior is __undefined__ if the string is empty.

## hash

Hashes the string, equivalent to `std::hash<string_view_t>{}(str)`.

```cpp
size_type hash() const noexcept;
```

## *

Aggregates the values of individual bytes of a string.

```cpp
size_type bytesum() const noexcept;
```

## fill_random

Overwrites the string with random binary data.

```cpp
string & fill_random(std::uint64_t nonce) noexcept;
```

```cpp
string & fill_random() noexcept;
```

This overload produces the nonce from a static variable, incrementing it each time. In this case the undefined behaviour in concurrent environments may play in our favor, but it's recommended to use the other overload in such cases.

- `nonce` (in): "Number used once" seeding the random number generator, __never__ repeat it!

See also: [sz_fill_random_best](https://www.unum.cloud/docs/stringzilla/c/sorting-and-sets.md#sz_fill_random_best)

## replace_all

Replaces ____(in-place) all occurrences of a given string with the `replacement`.

```cpp
status_t replace_all(
    string_view_t pattern,
    string_view_t replacement) noexcept;
```

```cpp
status_t replace_all(
    byteset_t pattern,
    string_view_t replacement) noexcept;
```

Replaces ____(in-place) all occurrences of a given character set with the `replacement` string.

The implementation is less composable than search ranges combined with a replacing mapping for matches, and may be suboptimal when exporting the cleaned-up string to another buffer, or when this string is made exclusively of the pattern.

Notes: Similar to [`boost::algorithm::replace_all`](#replace_all) and Python's [`str.replace`](#replace).

## lookup

Replaces ____(in-place) all characters in the string using the provided lookup `table`.

```cpp
string & lookup(look_up_table_t const & table) noexcept;
```

```cpp
void lookup(
    look_up_table_t const & table,
    pointer output) const noexcept;
```

Maps all characters in the current string into the `output` buffer using the provided lookup `table`.

- `output` (out): The buffer to write the transformed string into.

See also: [sz_strings_lookup_best](https://www.unum.cloud/docs/stringzilla/c/trimming-and-translating.md#sz_strings_lookup_best)

## utf8_count

Count UTF-8 characters in the string (not bytes).

```cpp
size_type utf8_count() const noexcept;
```

## utf8_seek

Find the byte offset of the nth UTF-8 character.

```cpp
size_type utf8_seek(size_type n) const noexcept;
```

- `n` (in): The character index (0-based).

## utf8_*_runes

Iterate over UTF-8 characters (codepoints) in the string.

```cpp
utf8_runes_view<string_view_t> utf8__runes() const noexcept;
```

## utf8_split_newlines

Lazily splits into the lines __between__ Unicode newlines, while [utf8_newlines](#utf8_newlines) yields the newline runs.

```cpp
utf8_split_newlines_view<string_view_t> utf8_split_newlines() const noexcept;
```

## utf8_*_newlines

Lazily yields the Unicode newline runs themselves (LF, CR, CRLF, NEL, LS, PS, ...).

```cpp
utf8_newlines_view<string_view_t> utf8__newlines() const noexcept;
```

## utf8_split_whitespaces

Lazily splits into the tokens __between__ Unicode whitespace runs (empties kept; `.skip_empty()` drops).

```cpp
utf8_split_whitespaces_view<string_view_t> utf8_split_whitespaces() const noexcept;
```

## utf8_*_whitespaces

Lazily yields the Unicode whitespace runs themselves.

```cpp
utf8_whitespaces_view<string_view_t> utf8__whitespaces() const noexcept;
```

## utf8_split_delimiters

Lazily splits into the fields __between__ any Unicode delimiter (P/S/Z); the superset of utf8_split_whitespaces().

```cpp
utf8_split_delimiters_view<string_view_t> utf8_split_delimiters() const noexcept;
```

## utf8_*_delimiters

Lazily yields the Unicode delimiter runs themselves (punctuation, symbols, separators).

```cpp
utf8_delimiters_view<string_view_t> utf8__delimiters() const noexcept;
```

## utf8_wordbreaks

Lazily yields the UAX-29 word segments, in order (words + the separators between them; they tile).

```cpp
utf8_wordbreaks_view<string_view_t> utf8_wordbreaks() const noexcept;
```

## utf8_uncased_fold

Apply Unicode case folding to the string in-place.

```cpp
status_t utf8_uncased_fold() noexcept;
```

Case folding normalizes text for uncased comparisons by mapping uppercase letters to their lowercase equivalents and handling special expansions defined in Unicode CaseFolding.txt.

Notes: The string may grow due to expansions, like U+00DF → "ss", by 3× in the worst case.

## utf8_find_*_find_denormalized

Return a pointer to the first byte violating the given Unicode normalization form.

```cpp
sz_cptr_t utf8_find__find_denormalized(sz_normal_form_t form) const noexcept;
```

- `form` (in): One of [`sz_normal_form_nfd_k`](https://www.unum.cloud/docs/stringzilla/c/case-folding-and-normalization.md#sz_normal_form_nfd_k), [`sz_normal_form_nfc_k`](https://www.unum.cloud/docs/stringzilla/c/case-folding-and-normalization.md#sz_normal_form_nfc_k), [`sz_normal_form_nfkd_k`](https://www.unum.cloud/docs/stringzilla/c/case-folding-and-normalization.md#sz_normal_form_nfkd_k), or [`sz_normal_form_nfkc_k`](https://www.unum.cloud/docs/stringzilla/c/case-folding-and-normalization.md#sz_normal_form_nfkc_k).

## is_*_normalized

Check whether the string is already in the given Unicode normalization form.

```cpp
bool is__normalized(sz_normal_form_t form) const noexcept;
```

- `form` (in): One of [`sz_normal_form_nfd_k`](https://www.unum.cloud/docs/stringzilla/c/case-folding-and-normalization.md#sz_normal_form_nfd_k), [`sz_normal_form_nfc_k`](https://www.unum.cloud/docs/stringzilla/c/case-folding-and-normalization.md#sz_normal_form_nfc_k), [`sz_normal_form_nfkd_k`](https://www.unum.cloud/docs/stringzilla/c/case-folding-and-normalization.md#sz_normal_form_nfkd_k), or [`sz_normal_form_nfkc_k`](https://www.unum.cloud/docs/stringzilla/c/case-folding-and-normalization.md#sz_normal_form_nfkc_k).

## utf8_normalize

Transform the string in-place into the given Unicode normalization form.

```cpp
status_t utf8_normalize(sz_normal_form_t form) noexcept;
```

Normalization may expand the byte length (e.g., NFC → NFD decomposes composed characters). Worst-case output is 18× the input length.

- `form` (in): One of [`sz_normal_form_nfd_k`](https://www.unum.cloud/docs/stringzilla/c/case-folding-and-normalization.md#sz_normal_form_nfd_k), [`sz_normal_form_nfc_k`](https://www.unum.cloud/docs/stringzilla/c/case-folding-and-normalization.md#sz_normal_form_nfc_k), [`sz_normal_form_nfkd_k`](https://www.unum.cloud/docs/stringzilla/c/case-folding-and-normalization.md#sz_normal_form_nfkd_k), or [`sz_normal_form_nfkc_k`](https://www.unum.cloud/docs/stringzilla/c/case-folding-and-normalization.md#sz_normal_form_nfkc_k).

## make

A new string holding `content`, in memory of [`allocator`](#allocator).

```cpp
expected<string> make(
    string_view_t content,
    allocator_type_ const & allocator = allocator_type_()) noexcept;
```

```cpp
template <typename first_type_, typename second_type_>
expected<string> make(
    concatenation<first_type_, second_type_> const & expression,
    allocator_type_ const & allocator = allocator_type_()) noexcept;
```

A new string holding a lazy concatenation, like `name | "\@" | domain`, in one allocation.

## string_slice

A string slice (view/span) class implementing a superset of C++23 functionality with much faster SIMD-accelerated substring search and approximate matching.

```cpp
template <typename char_type_>
class string_slice
```

Constructors are `constexpr` enabling `_sz` literals.

## npos

Special value for missing matches.

```cpp
size_type npos;
```

We take the largest 63-bit unsigned integer on 64-bit machines. We take the largest 31-bit unsigned integer on 32-bit machines.

## string_slice

```cpp
constexpr string_slice() noexcept;
```

```cpp
constexpr string_slice(pointer c_string) noexcept;
```

```cpp
constexpr string_slice(pointer c_string, size_type length) noexcept;
```

```cpp
string_slice(string_slice const & other) noexcept=default;
```

```cpp
string_slice(std::nullptr_t)=delete;
```

## operator=

```cpp
string_slice & operator=(string_slice const & other) noexcept=default;
```

## swap

Exchanges the view with that of the `other`.

```cpp
void swap(string_slice_t & other) noexcept;
```

## operator[]

Equivalent to Python's `"abc"[-3:-1]`.

```cpp
reference operator[](size_type pos) const noexcept;
```

```cpp
string_slice_t operator[](
    std::initializer_list<difference_type> signed_offsets) const noexcept;
```

Equivalent to Python's `"abc"[-3:-1]`.

Exception-safe, unlike STL's [`substr`](#substr). Supports signed and unsigned intervals.

## front

The slice that would be dropped by [`remove_prefix`](#remove_prefix), that accepts signed arguments and does no bounds checking.

```cpp
reference front() const noexcept;
```

```cpp
string_slice_t front(difference_type signed_offset) const noexcept;
```

The slice that would be dropped by [`remove_prefix`](#remove_prefix), that accepts signed arguments and does no bounds checking.

Equivalent to Python's `"abc"[:2]` and `"abc"[:-1]`.

Warnings: Undefined behavior if `signed_offset` is above size(), below −size(), or −0.

## back

The slice that would be dropped by [`remove_suffix`](#remove_suffix), that accepts signed arguments and does no bounds checking.

```cpp
reference back() const noexcept;
```

```cpp
string_slice_t back(difference_type signed_offset) const noexcept;
```

The slice that would be dropped by [`remove_suffix`](#remove_suffix), that accepts signed arguments and does no bounds checking.

Equivalent to Python's `"abc"[2:]` and `"abc"[-1:]`.

Warnings: Undefined behavior if `signed_offset` is above size(), below −size(), or −0.

## sat

Signed alternative to `at()`.

```cpp
reference sat(difference_type signed_offset) const noexcept;
```

Handy if you often write `str[str.size() - 2]`.

Warnings: The behavior is __undefined__ if the position is beyond bounds.

## sub

Equivalent to Python's `"abc"[-3:-1]`.

```cpp
string_slice_t sub(
    difference_type signed_start_offset,
    difference_type signed_end_offset = npos) const noexcept;
```

Exception-safe, unlike STL's [`substr`](#substr). Supports signed and unsigned intervals.

## copy

Exports this entire view.

```cpp
size_type copy(value_type *destination) const noexcept;
```

```cpp
size_type copy(
    value_type *destination,
    size_type count,
    size_type n = 0) const noexcept;
```

Exports at most [`count`](https://www.unum.cloud/docs/stringzilla/cpp/runtime-dispatch.md#count) bytes of this view after the first `n`, none when `n` passes the end.

Not an STL function, but useful for concatenations. The STL variant expects at least two arguments.

## remove_prefix

Removes the first `n` bytes from the view.

```cpp
void remove_prefix(size_type n) noexcept;
```

```cpp
string_slice_t remove_prefix(string_view_t other) const noexcept;
```

Python-like convenience function, dropping the matching prefix.

Warnings: The behavior is __undefined__ if `n > size()`.

## remove_suffix

Removes the last `n` bytes from the view.

```cpp
void remove_suffix(size_type n) noexcept;
```

```cpp
string_slice_t remove_suffix(string_view_t other) const noexcept;
```

Python-like convenience function, dropping the matching suffix.

Warnings: The behavior is __undefined__ if `n > size()`.

## substr

Added for STL compatibility.

```cpp
string_slice_t substr() const noexcept;
```

```cpp
string_slice_t substr(size_type n) const noexcept;
```

Return a slice of this view after first `n` bytes, empty when `n` passes the end, like Python's `text[n:]`.

```cpp
string_slice_t substr(size_type n, size_type count) const noexcept;
```

Return a slice of this view after first `n` bytes, taking at most [`count`](https://www.unum.cloud/docs/stringzilla/cpp/runtime-dispatch.md#count) bytes, empty when `n` passes the end, like Python's `text[n:n + count]`.

## compare

Compares two strings lexicographically.

```cpp
int compare(string_view_t other) const noexcept;
```

```cpp
int compare(
    size_type pos1,
    size_type count1,
    string_view_t other) const noexcept;
```

Compares up to `count1` bytes at `pos1` with `other`, lexicographically, then by length on a common prefix.

```cpp
int compare(
    size_type pos1,
    size_type count1,
    string_view_t other,
    size_type pos2,
    size_type count2) const noexcept;
```

Compares up to `count1` bytes at `pos1` with up to `count2` bytes at `pos2` of `other`, lexicographically, then by length on a common prefix.

```cpp
int compare(const_pointer other) const noexcept;
```

```cpp
int compare(
    size_type pos1,
    size_type count1,
    const_pointer other) const noexcept;
```

Compares up to `count1` bytes at `pos1` with `other`, lexicographically, then by length on a common prefix.

```cpp
int compare(
    size_type pos1,
    size_type count1,
    const_pointer other,
    size_type count2) const noexcept;
```

Compares up to `count1` bytes at `pos1` with the first `count2` bytes of `other`, lexicographically, then by length on a common prefix.

If prefix matches, lengths are compared.

Notes: A `pos1` past the end compares an empty slice.

Notes: A position past the end compares an empty slice.

## operator==

Checks if the string is equal to the other string.

```cpp
bool operator==(string_view_t other) const noexcept;
```

```cpp
bool operator==(
    concatenation<string_view_t, string_view_t> const & other) const noexcept;
```

Checks if the string is equal to a concatenation of two strings.

## operator<=>

Computes the lexicographic ordering between this and the ::other string.

```cpp
std::strong_ordering operator<=>(string_view_t other) const noexcept;
```

## starts_with

Checks if the string starts with the other string.

```cpp
bool starts_with(string_view_t other) const noexcept;
```

```cpp
bool starts_with(const_pointer other) const noexcept;
```

```cpp
bool starts_with(value_type other) const noexcept;
```

Checks if the string starts with the other character.

## ends_with

Checks if the string ends with the other string.

```cpp
bool ends_with(string_view_t other) const noexcept;
```

```cpp
bool ends_with(const_pointer other) const noexcept;
```

```cpp
bool ends_with(value_type other) const noexcept;
```

Checks if the string ends with the other character.

## contains

Checks if the string contains the given substring.

```cpp
bool contains(string_view_t other) const noexcept;
```

```cpp
bool contains(value_type character) const noexcept;
```

```cpp
bool contains(const_pointer other) const noexcept;
```

Checks if the string contains the given null-terminated substring.

## find

Find the first occurrence of a substring, skipping the first `skip` characters.

```cpp
size_type find(string_view_t other, size_type skip = 0) const noexcept;
```

```cpp
size_type find(value_type character, size_type skip = 0) const noexcept;
```

Find the first occurrence of a character, skipping the first `skip` characters.

```cpp
size_type find(
    const_pointer other,
    size_type pos,
    size_type count) const noexcept;
```

```cpp
size_type find(byteset_t set) const noexcept;
```

Find the first occurrence of a character from a set.

Returns: For an __empty__ `other`, `skip`.

Returns: [`npos`](#npos) if `skip > size()`.

Returns: For an __empty__ `other`, `pos`; delegates to the `string_view_t` overload.

Returns: [`npos`](#npos) if `pos > size()`.

## rfind

Find the last occurrence of a substring.

```cpp
size_type rfind(string_view_t other) const noexcept;
```

```cpp
size_type rfind(string_view_t other, size_type until) const noexcept;
```

Find the last occurrence of a substring, within first `until` characters.

```cpp
size_type rfind(value_type character) const noexcept;
```

Find the last occurrence of a character.

```cpp
size_type rfind(value_type character, size_type until) const noexcept;
```

Find the last occurrence of a character, within first `until` characters.

```cpp
size_type rfind(
    const_pointer other,
    size_type until,
    size_type count) const noexcept;
```

Find the last occurrence of a substring, within first `until` characters.

```cpp
size_type rfind(byteset_t set) const noexcept;
```

Find the last occurrence of a character from a set.

Returns: `size()` for an __empty__ `other`.

Returns: For an __empty__ `other`, `min(until, size())`.

Returns: For an __empty__ `other`, `min(until, size())`; delegates to and is consistent with the `string_view_t` overload above.

## partition

Split the string into three parts, before the match, the match itself, and after it.

```cpp
partition_type partition(string_view_t pattern) const noexcept;
```

```cpp
partition_type partition(value_type pattern) const noexcept;
```

```cpp
partition_type partition(byteset_t pattern) const noexcept;
```

## rpartition

Split the string into three parts, before the __last__ match, the last match itself, and after it.

```cpp
partition_type rpartition(string_view_t pattern) const noexcept;
```

```cpp
partition_type rpartition(value_type pattern) const noexcept;
```

```cpp
partition_type rpartition(byteset_t pattern) const noexcept;
```

## operator|

Lazily concatenates two slices into an expression template, without allocating.

```cpp
concatenation<string_view_t, string_view_t> operator|(
    string_view_t other) const noexcept;
```

See also: [concatenate](#concatenate) for the variadic form, and the converting constructor of `[string](#string)` that materializes the expression.

## find_first_of

Find the first occurrence of a character from a `set`.

```cpp
size_type find_first_of(
    byteset_t set,
    size_type skip = 0) const noexcept;
```

```cpp
size_type find_first_of(
    string_view_t other,
    size_type skip = 0) const noexcept;
```

Find the first occurrence of a character from the `other` string.

```cpp
size_type find_first_of(
    const_pointer other,
    size_type skip,
    size_type count) const noexcept;
```

Find the first occurrence of a character from the `other` string.

- `set` (in): The characters to match.
- `skip` (in): Number of characters to skip before the search.
- `other` (in): The characters to match.
- `count` (in): Number of characters at `other`.

## find_first_not_of

Find the first occurrence of a character outside a `set`.

```cpp
size_type find_first_not_of(
    byteset_t set,
    size_type skip = 0) const noexcept;
```

```cpp
size_type find_first_not_of(
    string_view_t other,
    size_type skip = 0) const noexcept;
```

Find the first occurrence of a character missing in the `other` string.

```cpp
size_type find_first_not_of(
    const_pointer other,
    size_type skip,
    size_type count) const noexcept;
```

Find the first occurrence of a character missing in the `other` string.

- `set` (in): The characters to avoid.
- `skip` (in): The number of first characters to be skipped.
- `other` (in): The characters to avoid.
- `count` (in): Number of characters at `other`.

## find_last_of

Find the last occurrence of a character from a `set`.

```cpp
size_type find_last_of(byteset_t set) const noexcept;
```

```cpp
size_type find_last_of(byteset_t set, size_type until) const noexcept;
```

```cpp
size_type find_last_of(
    string_view_t other,
    size_type until = npos) const noexcept;
```

Find the last occurrence of a character from the `other` string.

```cpp
size_type find_last_of(
    const_pointer other,
    size_type until,
    size_type count) const noexcept;
```

Find the last occurrence of a character from the `other` string.

- `until` (in): The offset of the last character to be considered.
- `other` (in): The characters to match.
- `count` (in): Number of characters at `other`.

## find_last_not_of

Find the last occurrence of a character outside a `set`.

```cpp
size_type find_last_not_of(byteset_t set) const noexcept;
```

```cpp
size_type find_last_not_of(
    byteset_t set,
    size_type until) const noexcept;
```

```cpp
size_type find_last_not_of(
    string_view_t other,
    size_type until = npos) const noexcept;
```

Find the last occurrence of a character missing in the `other` string.

```cpp
size_type find_last_not_of(
    const_pointer other,
    size_type until,
    size_type count) const noexcept;
```

Find the last occurrence of a character missing in the `other` string.

- `until` (in): The offset of the last character to be considered.
- `other` (in): The characters to avoid.
- `count` (in): Number of characters at `other`.

## utf8_count

Count the number of UTF-8 characters (not bytes) in the string.

```cpp
size_type utf8_count() const noexcept;
```

## utf8_seek

Find the byte offset of the Nth UTF-8 character.

```cpp
size_type utf8_seek(size_type n) const noexcept;
```

- `n` (in): Zero-indexed character position.

## utf8_uncased_order

Compares two strings lexicographically ignoring case, with lengths breaking ties.

```cpp
int utf8_uncased_order(string_view_t other) const noexcept;
```

## utf8_uncased_search

Find the byte offset of the first occurrence of a substring.

```cpp
sized_match_t utf8_uncased_search(string_view_t other) const noexcept;
```

```cpp
sized_match_t utf8_uncased_search(
    utf8_uncased_needle_t const & needle) const noexcept;
```

Find the byte offset of the first occurrence of a prepared uncased needle.

- `needle` (in): A needle prepared once for repeated searches.

## utf8_uncased_matches

Lazily yields all __non-overlapping__ case-insensitive matches of a prepared needle.

```cpp
find_matches_view<string_view_t, matcher_utf8_uncased_search<string_view_t>> utf8_uncased_matches(
    utf8_uncased_needle_t const & needle) const noexcept;
```

```cpp
find_matches_view<string_view_t, matcher_utf8_uncased_search<string_view_t>> utf8_uncased_matches(
    string_view_t needle) const noexcept;
```

A lazy view of all __non-overlapping__ case-insensitive matches of a UTF-8 needle.

- `needle` (in): A needle prepared once, reused across the whole scan.

Notes: An __empty__ needle matches at every codepoint boundary, the end included.

## utf8_split_newlines

Lazily splits the string into the lines __between__ Unicode newlines (UTF-8 aware).

```cpp
utf8_split_newlines_view<string_slice_t> utf8_split_newlines() const noexcept;
```

See also: utf8_newlines() for the newline runs themselves.

## utf8_split_whitespaces

Lazily splits the UTF-8 string into the tokens __between__ Unicode whitespace runs.

```cpp
utf8_split_whitespaces_view<string_slice_t> utf8_split_whitespaces() const noexcept;
```

See also: utf8_whitespaces() for the whitespace runs themselves.

## utf8_split_delimiters

Lazily splits the string into the fields __between__ any Unicode delimiter (punctuation/symbol/separator).

```cpp
utf8_split_delimiters_view<string_slice_t> utf8_split_delimiters() const noexcept;
```

See also: utf8_delimiters() for the delimiter runs themselves.

## utf8_wordbreaks

Lazily yields the UAX-29 word segments in order, both the words and the separators.

```cpp
utf8_wordbreaks_view<string_slice_t> utf8_wordbreaks() const noexcept;
```

The segments tile the input contiguously - each yielded slice is the span between consecutive TR29 word boundaries, so concatenating them reconstructs the input.

## utf8_graphemes

Lazily splits the string into UAX-29 grapheme clusters, in order.

```cpp
utf8_graphemes_view<string_slice_t> utf8_graphemes() const noexcept;
```

Unlike `utf8_split_whitespaces()`, the graphemes tile the input contiguously, with no empty segments: each yielded slice spans two consecutive TR29 grapheme cluster boundaries.

## utf8_sentences

Lazily splits the string into UAX-29 sentences, in order.

```cpp
utf8_sentences_view<string_slice_t> utf8_sentences() const noexcept;
```

Unlike `utf8_split_whitespaces()`, the sentences tile the input contiguously (no empty segments). Each yielded slice is the span between consecutive TR29 sentence boundaries.

## utf8_linebreaks

Lazily splits the string into UAX-14 line-breakable segments, in order.

```cpp
utf8_linebreaks_view<string_slice_t> utf8_linebreaks() const noexcept;
```

Distinct from `utf8_split_newlines()`, which splits only on hard (mandatory) Unicode newline characters. Here every byte belongs to exactly one segment ending at an allowed line break opportunity, including both the mandatory hard breaks and the soft wrap points.

## find_all

Find all potentially __overlapping__ occurrences of a given string.

```cpp
find_all_type find_all(
    string_view_t needle,
    include_overlaps_t = {}) const noexcept;
```

```cpp
find_disjoint_type find_all(
    string_view_t needle,
    exclude_overlaps_t) const noexcept;
```

Find all __non-overlapping__ occurrences of a given string.

```cpp
find_all_chars_type find_all(byteset_t set) const noexcept;
```

Find all occurrences of given characters.

Notes: For an __empty__ `needle`, yields `size() + 1` empty matches - one per valid `find(needle, skip)` offset from `0` to `size()` inclusive.

Notes: For an __empty__ `needle`, yields `size() + 1` empty matches.

See also: [find_all](https://www.unum.cloud/docs/stringzilla/cpp/searching-and-counting.md#find_all)

## rfind_all

Find all potentially __overlapping__ occurrences of a string in __reverse__ order.

```cpp
rfind_all_type rfind_all(
    string_view_t needle,
    include_overlaps_t = {}) const noexcept;
```

```cpp
rfind_disjoint_type rfind_all(
    string_view_t needle,
    exclude_overlaps_t) const noexcept;
```

Find all __non-overlapping__ occurrences of a given string in __reverse__ order.

```cpp
rfind_all_chars_type rfind_all(byteset_t set) const noexcept;
```

Find all occurrences of given characters in __reverse__ order.

Notes: For an __empty__ `needle`, yields `size() + 1` empty matches.

See also: [find_all](https://www.unum.cloud/docs/stringzilla/cpp/searching-and-counting.md#find_all)

## split

Split around occurrences of a given string.

```cpp
split_type split(string_view_t delimiter) const noexcept;
```

```cpp
split_chars_type split(
    byteset_t set = whitespaces_set()) const noexcept;
```

Split around occurrences of given characters.

Notes: An __empty__ `delimiter` never splits, yielding the whole string as the only segment.

## rsplit

Split around occurrences of a given string in __reverse__ order.

```cpp
rsplit_type rsplit(string_view_t delimiter) const noexcept;
```

```cpp
rsplit_chars_type rsplit(
    byteset_t set = whitespaces_set()) const noexcept;
```

Split around occurrences of given characters in __reverse__ order.

Notes: An __empty__ `delimiter` never splits, yielding the whole string as the only segment.

See also: [split](https://www.unum.cloud/docs/stringzilla/cpp/splitting-and-partitioning.md#split)

## splitlines

Split around the occurrences of all newline characters.

```cpp
split_chars_type splitlines() const noexcept;
```

## hash

Hashes the string, equivalent to `std::hash<string_view_t>{}(str)`.

```cpp
size_type hash(std::uint64_t seed = 0) const noexcept;
```

## hash_multiseed

Hashes the string under each of `seeds` at once, writing one hash per seed into [`hashes`](#hashes).

```cpp
void hash_multiseed(
    std::span<std::uint64_t const> seeds,
    std::span<std::uint64_t> hashes) const noexcept;
```

Notes: Equivalent to `hashes[i] = hash(seeds[i])`, but amortizes the input loading.

See also: [sz_hash_multiseed_best](https://www.unum.cloud/docs/stringzilla/c/hashing-and-checksums.md#sz_hash_multiseed_best)

## as_set

Populate a character set with characters present in this string.

```cpp
byteset_t as_set() const noexcept;
```

## strings

An owned column: the C span and the allocator its blocks came from, the twin of [`string`](#string).

```cpp
template <typename allocator_type_ = heap_alloc<char>>
struct strings
```

Only the conversions of `[strings_view_t](#strings_view_t)` and the splits fill one, so it never grows and moves without copies. Its offsets are 32-bit while the payload fits in 4 GiB and 64-bit beyond.

## raw

The tape, zeroed while empty.

```cpp
sz_strings_span_t raw;
```

## allocator

Where both blocks of [`raw`](#raw) come from and return to.

```cpp
allocator_type_ allocator;
```

## strings

```cpp
strings() noexcept=default;
```

```cpp
strings(allocator_type_ allocator) noexcept;
```

```cpp
strings(strings const &)=delete;
```

```cpp
strings(strings && other) noexcept;
```

## operator=

```cpp
strings & operator=(strings const &)=delete;
```

```cpp
strings & operator=(strings && other) noexcept;
```

## view

Defined once `[string_slice](#string_slice)` is complete: inside the class, nvcc's front end, emulating Clang, asserts resolving the `[strings_view_t](#strings_view_t)` span constructor against the incomplete slice.

```cpp
strings_view_t view() const noexcept;
```

## split

Splits `text` at the bytes of `delimiters` into its parts, like [`bytes.split`](https://www.unum.cloud/docs/stringzilla/cpp/splitting-and-partitioning.md#split).

```cpp
expected<strings> split(
    string_view_t text,
    byteset_t const & delimiters,
    sz_split_kind_t kind,
    allocator_type_ allocator = {},
    sz_capability_t capabilities = default_capabilities(),
    sz_stream_t stream = nullptr) noexcept;
```

See also: [sz_strings_split_best](https://www.unum.cloud/docs/stringzilla/c/splitting-and-partitioning.md#sz_strings_split_best)

## split_lines

Splits `text` into lines without their breaks, like [`str.splitlines`](#splitlines).

```cpp
expected<strings> split_lines(
    string_view_t text,
    allocator_type_ allocator = {},
    sz_capability_t capabilities = default_capabilities(),
    sz_stream_t stream = nullptr) noexcept;
```

See also: [sz_strings_split_lines_best](https://www.unum.cloud/docs/stringzilla/c/splitting-and-partitioning.md#sz_strings_split_lines_best)

## strings_view_t

A borrowed column in any layout of `[sz_strings_view_t](https://www.unum.cloud/docs/stringzilla/c/types.md#sz_strings_view_t)`, the twin of `string_view_t`.

```cpp
struct strings_view_t
```

Every conversion reads the whole column into a fresh [`strings`](#strings), whose blocks come from the given allocator, and leaves it empty on failure.

## raw

The C view every member reads.

```cpp
sz_strings_view_t raw;
```

## strings_view_t

Wraps a C view, like one over records or NUL-padded rows.

```cpp
strings_view_t(sz_strings_view_t raw) noexcept;
```

```cpp
strings_view_t(
    char const *data,
    sz_u32_t const *offsets,
    std::size_t count) noexcept;
```

An Apache Arrow `String` column: string i is `[offsets[i], offsets[i + 1])` of `data`.

```cpp
strings_view_t(
    char const *data,
    sz_u64_t const *offsets,
    std::size_t count) noexcept;
```

An Apache Arrow `LargeString` column, the same with 64-bit offsets.

```cpp
strings_view_t(std::span<string_view_t const> strings) noexcept;
```

Views [`strings`](#strings) through an accessor, copying no bytes, so they must outlive the view.

```cpp
template <typename allocator_type_>
strings_view_t(strings<allocator_type_> const & strings) noexcept;
```

Views the tape of [`strings`](#strings).

## find

Finds `needle` in every string, like a `LIKE` 'needle' filter over a column.

```cpp
status_t find(
    string_view_t needle,
    std::span<std::size_t> positions,
    sz_capability_t capabilities = default_capabilities(),
    sz_stream_t stream = nullptr) const noexcept;
```

- `needle` (in): The bytes to look for.
- `positions` (out): The offset of each string's first match, or `STRINGZILLA_SIZE_MAX`.
- `capabilities` (in): Capabilities to pick from.
- `stream` (in): Null on the CPU, or the stream of the device `capabilities` describes.

See also: [sz_find_strings_best](https://www.unum.cloud/docs/stringzilla/c/searching-and-counting.md#sz_find_strings_best)

Statuses: - [`unexpected_dimensions_k`](#unexpected_dimensions_k) `positions` is too short.

## hashes

Hashes every string under one `seed`, each as `[string_view_t::hash](https://www.unum.cloud/docs/stringzilla/cpp/hashing-and-checksums.md#hash)` would.

```cpp
status_t hashes(
    std::span<u64_t> hashes,
    u64_t seed = 0,
    sz_capability_t capabilities = default_capabilities(),
    sz_stream_t stream = nullptr) const noexcept;
```

See also: [sz_hash_strings_best](https://www.unum.cloud/docs/stringzilla/c/hashing-and-checksums.md#sz_hash_strings_best)

Statuses: - [`unexpected_dimensions_k`](#unexpected_dimensions_k) [`hashes`](#hashes) is too short.

## utf8_count

Validates every string as UTF-8 and, unless `runes` is empty, counts its runes.

```cpp
status_t utf8_count(
    std::span<std::size_t> runes,
    std::size_t & malformed_index,
    sz_capability_t capabilities = default_capabilities(),
    sz_stream_t stream = nullptr) const noexcept;
```

- `runes` (out): Empty, or each string's runes, unspecified from the first ill-formed one.
- `malformed_index` (out): The first ill-formed string, or `size()` if none is ill-formed.
- `capabilities` (in): Capabilities to pick from.
- `stream` (in): Null on the CPU, or the stream of the device `capabilities` describes.

See also: [sz_utf8_count_strings_best](https://www.unum.cloud/docs/stringzilla/c/searching-and-counting.md#sz_utf8_count_strings_best)

Statuses: - [`invalid_utf8_k`](#invalid_utf8_k) A string is ill-formed.
- [`unexpected_dimensions_k`](#unexpected_dimensions_k) `runes` is too short.

## to_rows

Writes every string into a NUL-padded row of `width` bytes, truncating longer ones.

```cpp
expected<std::size_t> to_rows(
    std::span<char> rows,
    std::size_t width,
    sz_capability_t capabilities = default_capabilities(),
    sz_stream_t stream = nullptr) const noexcept;
```

See also: [sz_strings_to_rows_best](https://www.unum.cloud/docs/stringzilla/c/sorting-and-sets.md#sz_strings_to_rows_best)

## gather

Copies every string into one tape, whatever the layout.

```cpp
template <typename allocator_type_ = heap_alloc<char>>
expected<strings<allocator_type_>> gather(
    allocator_type_ allocator = {},
    sz_capability_t capabilities = default_capabilities(),
    sz_stream_t stream = nullptr) const noexcept;
```

See also: [sz_strings_to_tape_best](https://www.unum.cloud/docs/stringzilla/c/sorting-and-sets.md#sz_strings_to_tape_best)

## escape

Escapes every string for `kind`, like JSON or CSV.

```cpp
template <typename allocator_type_ = heap_alloc<char>>
expected<strings<allocator_type_>> escape(
    sz_escape_kind_t kind,
    allocator_type_ allocator = {},
    sz_capability_t capabilities = default_capabilities(),
    sz_stream_t stream = nullptr) const noexcept;
```

See also: [sz_strings_escape_best](https://www.unum.cloud/docs/stringzilla/c/sorting-and-sets.md#sz_strings_escape_best)

## unescape

Unescapes every string from `kind`, checking all of them before writing any.

```cpp
template <typename allocator_type_ = heap_alloc<char>>
expected<strings<allocator_type_>> unescape(
    sz_escape_kind_t kind,
    std::size_t & malformed_index,
    allocator_type_ allocator = {},
    sz_capability_t capabilities = default_capabilities(),
    sz_stream_t stream = nullptr) const noexcept;
```

- `kind` (in): The text format the strings are in.
- `malformed_index` (out): The first malformed string, set on [`invalid_utf8_k`](#invalid_utf8_k).
- `allocator` (in): Source of the result's blocks.
- `capabilities` (in): Capabilities to pick from.
- `stream` (in): Null on the CPU, or the stream of the device `capabilities` describes.

See also: [sz_strings_unescape_best](https://www.unum.cloud/docs/stringzilla/c/sorting-and-sets.md#sz_strings_unescape_best)

## lookup

Maps every byte through `table`, like `tolower` does.

```cpp
template <typename allocator_type_ = heap_alloc<char>>
expected<strings<allocator_type_>> lookup(
    look_up_table_t const & table,
    allocator_type_ allocator = {},
    sz_capability_t capabilities = default_capabilities(),
    sz_stream_t stream = nullptr) const noexcept;
```

See also: [sz_strings_lookup_best](https://www.unum.cloud/docs/stringzilla/c/trimming-and-translating.md#sz_strings_lookup_best)

## normalize

Brings every string into the Unicode `form`, like NFC.

```cpp
template <typename allocator_type_ = heap_alloc<char>>
expected<strings<allocator_type_>> normalize(
    sz_normal_form_t form,
    allocator_type_ allocator = {},
    sz_capability_t capabilities = default_capabilities(),
    sz_stream_t stream = nullptr) const noexcept;
```

See also: [sz_strings_normalize_best](https://www.unum.cloud/docs/stringzilla/c/case-folding-and-normalization.md#sz_strings_normalize_best)

## join

Joins every string with `between` into one, like Python's [`str.join`](#join).

```cpp
template <typename allocator_type_ = std::allocator<char>>
expected<string<allocator_type_>> join(
    string_view_t between,
    allocator_type_ allocator = {},
    sz_capability_t capabilities = default_capabilities(),
    sz_stream_t stream = nullptr) const noexcept;
```

```cpp
template <typename allocator_type_ = std::allocator<char>>
expected<string<allocator_type_>> join(
    std::span<sz_strings_view_t const> columns,
    std::span<sz_string_view_t const> frames,
    string_view_t between,
    allocator_type_ allocator = {},
    sz_capability_t capabilities = default_capabilities(),
    sz_stream_t stream = nullptr) noexcept;
```

Writes row r of `columns` as `frames[0] + columns[0][r] + frames[1] + … + frames[n]`, with `between` between rows, like CSV lines or JSON arrays.

See also: [sz_strings_join_best](https://www.unum.cloud/docs/stringzilla/c/splitting-and-partitioning.md#sz_strings_join_best)

Statuses: - [`unexpected_dimensions_k`](#unexpected_dimensions_k) Uneven columns or `frames` is not one longer.

## ascii_letters

The concatenation of [`ascii_lowercase`](#ascii_lowercase) and [`ascii_uppercase`](#ascii_uppercase), independent of locale.

```cpp
carray<52> const & ascii_letters() noexcept;
```

See also: [https://docs.python.org/3/library/string.html#string.ascii_letters](https://docs.python.org/3/library/string.html#string.ascii_letters)

## ascii_lowercase

The lowercase letters "abcdefghijklmnopqrstuvwxyz".

```cpp
carray<26> const & ascii_lowercase() noexcept;
```

This value is not locale-dependent.

See also: [https://docs.python.org/3/library/string.html#string.ascii_lowercase](https://docs.python.org/3/library/string.html#string.ascii_lowercase)

## ascii_uppercase

The uppercase letters "ABCDEFGHIJKLMNOPQRSTUVWXYZ".

```cpp
carray<26> const & ascii_uppercase() noexcept;
```

This value is not locale-dependent.

See also: [https://docs.python.org/3/library/string.html#string.ascii_uppercase](https://docs.python.org/3/library/string.html#string.ascii_uppercase)

## ascii_printables

Printable ASCII characters, including: [`digits`](#digits), [`ascii_letters`](#ascii_letters), [`punctuation`](#punctuation), and `whitespace`.

```cpp
carray<100> const & ascii_printables() noexcept;
```

See also: [https://docs.python.org/3/library/string.html#string.printable](https://docs.python.org/3/library/string.html#string.printable)

## ascii_controls

Non-printable ASCII control characters.

```cpp
carray<33> const & ascii_controls() noexcept;
```

Includes all codes from 0 to 31 and 127.

## digits

The digits "0123456789".

```cpp
carray<10> const & digits() noexcept;
```

See also: [https://docs.python.org/3/library/string.html#string.digits](https://docs.python.org/3/library/string.html#string.digits)

## hexdigits

The letters "0123456789abcdefABCDEF".

```cpp
carray<22> const & hexdigits() noexcept;
```

See also: [https://docs.python.org/3/library/string.html#string.hexdigits](https://docs.python.org/3/library/string.html#string.hexdigits)

## octdigits

The letters "01234567".

```cpp
carray<8> const & octdigits() noexcept;
```

See also: [https://docs.python.org/3/library/string.html#string.octdigits](https://docs.python.org/3/library/string.html#string.octdigits)

## punctuation

The 32 ASCII punctuation characters of the C locale: every printable character that is neither a letter, a digit, nor whitespace.

```cpp
carray<32> const & punctuation() noexcept;
```

See also: [https://docs.python.org/3/library/string.html#string.punctuation](https://docs.python.org/3/library/string.html#string.punctuation)

## whitespaces

Whitespace ASCII characters: space, tab, linefeed, return, formfeed, and vertical tab.

```cpp
carray<6> const & whitespaces() noexcept;
```

See also: [https://docs.python.org/3/library/string.html#string.whitespace](https://docs.python.org/3/library/string.html#string.whitespace)

## newlines

ASCII characters that are considered line delimiters.

```cpp
carray<8> const & newlines() noexcept;
```

See also: [https://docs.python.org/3/library/stdtypes.html#str.splitlines](https://docs.python.org/3/library/stdtypes.html#str.splitlines)

## base64

ASCII characters forming the BASE64 encoding alphabet: a-z, A-Z, 0-9, +, and /.

```cpp
carray<64> const & base64() noexcept;
```

See also: [https://docs.python.org/3/library/base64.html](https://docs.python.org/3/library/base64.html)

## concatenate

Concatenates two strings into a template expression.

```cpp
template <typename first_type_, typename second_type_>
concatenation<typename concatenation_operand<first_type_>::type, typename concatenation_operand<second_type_>::type> concatenate(
    first_type_ && first,
    second_type_ && second) noexcept;
```

```cpp
template <typename first_type_, typename second_type_, typename... following_types_>
concatenation_result<first_type_, second_type_, following_types_...>::type concatenate(
    first_type_ && first,
    second_type_ && second,
    following_types_ &&... following) noexcept;
```

Concatenates two or more strings into a template expression.

See also: [concatenation](#concatenation) class for more details.

## succeeded

Whether `status` reports success.

```cpp
bool succeeded(status_t status) noexcept;
```

## failed

Whether `status` reports failure.

```cpp
bool failed(status_t status) noexcept;
```

## status_name

Static, English description of `status`.

```cpp
char const * status_name(status_t status) noexcept;
```

Never returns `nullptr`, never allocates.

## divide_round_up

Divides `x` by `divisor` and rounds up to the nearest integer.

```cpp
template <typename scalar_type_>
scalar_type_ divide_round_up(scalar_type_ x, scalar_type_ divisor);
```

Notes: This is equivalent to `ceil(x / divisor)`, but avoids floating-point arithmetic.

## round_up_to_multiple

Rounds `x` up to the nearest multiple of `divisor`.

```cpp
template <typename scalar_type_>
scalar_type_ round_up_to_multiple(scalar_type_ x, scalar_type_ divisor);
```

## bit_width

The number of significant bits in `x`, or zero when `x` is zero.

```cpp
template <typename scalar_type_>
int bit_width(scalar_type_ x) noexcept;
```

Widens to `u64_t` first, so one body serves every unsigned width - shifting a 32-bit value by 32 would be undefined even on a branch that never runs.

Notes: Unrolled rather than delegating to `sz_u64_clz`, which is an intrinsic wrapper and not `constexpr`.

## integer_square_root

Exact ⌊√x⌋ over integers, without floating-point arithmetic and without a loop.

```cpp
template <typename scalar_type_>
scalar_type_ integer_square_root(scalar_type_ x) noexcept;
```

Seeds a power of two at or above the root, then runs five Newton steps: each doubles the count of correct bits, and a 64-bit input has a 32-bit root, so 1 → 2 → 4 → 8 → 16 → 32 covers every width. Newton converges from above, so one clamp lands on the floor. Unlike `std::sqrt`, it is `constexpr`, which keeps it callable from CUDA device code.

## non_zero_if

Equivalent to `(condition &#63; value : 0)`, but avoids branching.

```cpp
template <typename value_type_>
value_type_ non_zero_if(
    value_type_ value,
    value_type_ condition) noexcept;
```

## trivial_swap

Analog to [`std::swap`](#swap) from `<utility>`, but also generates device code, unlike STL.

```cpp
template <typename value_type_>
void trivial_swap(value_type_ & x, value_type_ & y) noexcept;
```

