Skip to content
StrIterFromCstr

StrIterFromCstr

Description

Construct a forward-walking StrIter over an explicit (char *, n) byte range. Alias-reframe of the IterInitFromVec shape with caller-supplied length; alignment is fixed at 1. See IterInitFromVec for the overall borrowed-data semantics.

Parameters

Name Direction Description
s in Pointer to the first character. Must outlive the iterator.
n in Number of characters reachable through the iterator.

Success

Returns a compound-literal StrIter covering [s, s + n) with pos = 0, dir = 1.

Failure

Macro cannot fail. Passing n larger than the actual allocation is a usage error – subsequent reads will run past the end.

Usage example (Cross-references)

Usage examples (Cross-references)
    // bytes that sit past it in the backing buffer.
    bool test_striter_from_cstr_caps_length(void) {
        StrIter si = StrIterFromCstr("abcd", 2);
        if (StrIterRemainingLength(&si) != 2) {
            return false;
Last updated on