VecForeachPtrInRange

Table of Contents

VecForeachPtrInRange

Description

Iterate over elements in a specific range of the given vector v (as pointers). This is a convenience macro that iterates over a range using an internally managed index and provides a pointer to each element. The variable var is declared and defined by this macro as a pointer to the vector’s data type.

Parameters

NameDirectionDescription
vin,outVector to iterate over.
varinName of pointer variable to be used which’ll point to the current element.
startinStarting index (inclusive).
endinEnding index (exclusive).

Success

The body is executed for each element of the vector v from the start index to the end-1 index, with var pointing to each element.

Failure

If the vector v is NULL, its length is zero, or the range is invalid, the loop body will not be executed. Any failures within the VecForeachPtrInRangeIdx macro will result in a fatal log message and program termination.

Usage example (Cross-references)

    ///
    #define StrForeachPtrInRange(str, chrptr, start, end, body)                                                            \
    VecForeachPtrInRange((str), (chrptr), (start), (end), {body})
    
    #ifdef __cplusplus

Share :