cvector · Section 3
cvec_pop
NAME
cvec_pop - pop an element from the vector (type-inferred)
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/cvector.h> value = cvec_pop(v);
DESCRIPTION
Type-inferred wrapper for cvector_pop_back() that gives the popped element as a value and calls ccol__fatal_err() when the pop fails.
PARAMETERS
v Vector to pop from
RETURN VALUE
The value of the popped element.
NOTES
A failure stops the program. The macro gives a value, not a pointer, and it uses the GNU C statement expression extension. A vector whose element type is an array, such as char[32], is refused at compile time, because C can't give back an array as a value. Pop such an element into a buffer of the element type with cvector_pop_back().
EXAMPLES
cvec_construct(vec, int); cvec_push(vec, 42); int val = cvec_pop(vec); // val == 42 cvec_destroy(vec);