Skip to content

IterMustRead

Description

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

Success

Returns to the caller; the underlying IterRead succeeded.

Failure

Does not return - aborts via LOG_FATAL when the iterator is exhausted.

Usage example (Cross-references)

Usage examples (Cross-references)
        IterRead(&it, &v); // consume sole element
        // Now exhausted - this must abort.
        IterMustRead(&it, &v);
        return true; // unreachable
    }
    #define StrIterRead(mi, out) IterRead((mi), (out))
    /// Aborting variant of `StrIterRead`.
    #define StrIterMustRead(mi, out) IterMustRead((mi), (out))
    
    /// Propagating: writes `*out` with the current char; returns false at EOF.
        do {                                                                                                               \
            if (!IterRead((mi), (out))) {                                                                                  \
                LOG_FATAL("IterMustRead: iterator exhausted");                                                             \
            }                                                                                                              \
        } while (0)
Last updated on