Skip to content

VecEnd

Description

Pointer one past the last element of the vector. Suitable as an iteration sentinel for [begin, end) loops.

Parameters

Name Direction Description
v in Vector to query.

Usage example (Cross-references)

Usage examples (Cross-references)
            case VEC_CHAR_PTR_END : {
                if (VecLen(vec) > 0) {
                    char **end = VecEnd(vec);
                    (void)end; // Use the result to avoid warnings
                }
            case VEC_STR_END : {
                if (VecLen(vec) > 0) {
                    Str *end = VecEnd(vec);
                    (void)end; // Use the result to avoid warnings
                }
    
            case VEC_INT_END : {
                volatile void *end_ptr = VecEnd(vec);
                (void)end_ptr;
                break;
    // Test VecBegin and VecEnd functions
    bool test_vec_begin_end(void) {
        WriteFmt("Testing VecBegin and VecEnd\n");
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        // Get begin and end pointers
        int  *begin = VecBegin(&vec);
        char *end   = (char *)VecEnd(&vec);
    
        // Check that begin points to the first element
    /// TAGS: Str, Access, Iterator, End
    ///
    #define StrEnd(str) VecEnd(str)
    
    ///
Last updated on