VecPushFrontL
Description
Prepend a single element at the front of the vector. L-value ownership form.
Success
Returns true. The vector length grows by one; val occupies index 0; previous elements have shifted right by one. When the vector has no copy_init handler, val has been zeroed (moved-from); otherwise unchanged.
Failure
Returns false on allocation failure. Both vector and val are unchanged.
Usage example (Cross-references)
Usage examples (Cross-references)
// Test VecPushFrontL
int val2 = 20;
VecPushFrontL(&vec, val2);
// Test VecInsertL
// Test VecPushFrontL zero-on-take behavior with complex structures
bool test_lvalue_zero_on_take_pushfront(void) {
WriteFmt("Testing VecPushFrontL zero-on-take with complex structures\n");
// Create a test item
// Insert with L-value semantics at the front (vector takes ownership)
VecPushFrontL(&vec, item);
// Check that the item was zeroed
- In
Vec.Insert.c:453:
// Test VecPushFrontL
int val2 = 20;
VecPushFrontL(&vec, val2);
result = result && (val2 == 0); // Should be zeroed
- In
Insert.h:501:
/// TAGS: Vec, PushFront, Insert
///
#define VecPushFront(v, val) VecPushFrontL((v), (val))
///
- In
Insert.h:1021:
#define VecMustPushFrontL(v, val) \
do { \
if (!VecPushFrontL((v), (val))) { \
LOG_FATAL("VecMustPushFrontL failed"); \
} \- In
Insert.h:238:
/// TAGS: Str, PushFront, Char, LValue
///
#define StrPushFrontL(str, lval) VecPushFrontL((str), (lval))
///
Last updated on