Skip to content

IterMustMove

Description

Aborting variant of IterMove. See that macro for parameter semantics and success-state effects.

Success

Returns to the caller; the underlying IterMove succeeded.

Failure

Does not return - aborts via LOG_FATAL when the new position would be out of range.

Usage example (Cross-references)

Usage examples (Cross-references)
        BufIter  it     = from(buf, 3);
        // length=3, dir=+1: move by 4 lands past end.
        IterMustMove(&it, 4);
        return true; // unreachable
    }
    #define StrIterMove(si, n) IterMove((si), (n))
    /// Aborting variant of `StrIterMove`.
    #define StrIterMustMove(si, n) IterMustMove((si), (n))
    
    /// Propagating: advance one character; false if exhausted.
        do {                                                                                                               \
            if (!IterMove((mi), (n))) {                                                                                    \
                LOG_FATAL("IterMustMove: target position out of range");                                                   \
            }                                                                                                              \
        } while (0)
    /// TAGS: Iter, Move, Must, Abort
    ///
    #define IterMustNext(mi) IterMustMove((mi), 1)
    
    ///
    /// TAGS: Iter, Move, Must, Abort
    ///
    #define IterMustPrev(mi) IterMustMove((mi), -1)
    
    #endif // MISRA_STD_UTILITY_ITER_MOVE_H
Last updated on