Skip to content
C++

<vector> API Reference

C++ std::vector — a contiguous, dynamically-resizable array with O(1) random access.

By EZ4Code Team

std::vector

A sequence container that encapsulates dynamic size arrays.

std::vector::push_back(const T& value)

Appends the given element value to the end of the container.

Returns: void

std::vector::size() const noexcept -> size_t

Returns the number of elements currently in the container.

Returns: size_t

std::vector::at(size_t pos) -> reference

Returns a reference to the element at pos with bounds checking (throws std::out_of_range).

Returns: reference

std::vector::pop_back()

Removes the last element of the container. Calling on an empty vector is undefined.

Returns: void

std::vector::empty() const noexcept -> bool

Returns true if the container has no elements, false otherwise.

Returns: bool

std::vector::clear() noexcept

Erases all elements from the container, leaving size() == 0.

Returns: void

std::vector::begin() noexcept -> iterator

Returns an iterator to the first element of the container.

Returns: iterator

More C++ API References