folly::small_vector

Forward declaration of the small_vector container.

Synopsis

Declared in <folly/container/small_vector.h>

template<
    typename T,
    std::size_t M = 1,
    typename P = void>
class small_vector
    : public /* implementation-defined */::type

Base Classes

NameDescription
/* implementation-defined */::type

Type Aliases

NameDescription
allocator_type The allocator type (provided for std::vector compatibility).
const_iterator Const iterator over elements.
const_pointer Const pointer to an element.
const_reference Const reference to an element.
const_reverse_iterator Const reverse iterator over elements.
difference_type Signed integer type for the difference between two iterators.
iterator Iterator over elements.
pointer Pointer to an element.
reference Reference to an element.
reverse_iterator Reverse iterator over elements.
size_type Unsigned integer type used for sizes and indices.
value_type The type of the elements.

Member Functions

NameDescription
small_vector [constructor]Construct an empty small_vector.
small_vector [constructor]Copy-construct from another small_vector.
small_vector [constructor]Move-construct from another small_vector.
small_vector [constructor]Construct with n default-constructed elements.
small_vector [constructor]Construct from an initializer list.
small_vector [constructor]Allocator is unused here. It is taken in for compatibility with std::vector interface, but it will be ignored.
small_vector [constructor]Construct with n copies of a given value.
small_vector [constructor]Construct from an iterator range or from a (count, value) pair.
~small_vector [destructor]Destroy the small_vector and free any heap storage.
operator= Copy-assign the contents of another small_vector.
operator= Move-assign the contents of another small_vector.
assign Replace the contents with the elements of an initializer list.
assign Replace the contents with n copies of a value.
assign Replace the contents with the elements in an iterator range.
at Access the element at a given index, with bounds checking.
at Access the element at a given index, with bounds checking.
back Access the last element.
back Access the last element.
begin Return an iterator to the first element.
begin Return a const iterator to the first element.
capacity Return the number of elements the vector can hold without reallocating.
cbegin Return a const iterator to the first element.
cend Return a const iterator past the last element.
clear Remove all elements, leaving the vector empty.
crbegin Return a const reverse iterator to the last element.
crend Return a const reverse iterator past the first element.
data Return a pointer to the underlying element storage.
data Return a pointer to the underlying element storage.
emplace Construct a new element in place before a position.
emplace_back Construct a new element in place at the end.
empty Test whether the vector is empty.
end Return an iterator past the last element.
end Return a const iterator past the last element.
erase Remove the element at a given position.
erase Remove the elements in the range [q1, q2).]
front Access the first element.
front Access the first element.
get_allocator Return the allocator (provided for std::vector compatibility).
heap_allocation_size Returns the number of bytes used by the heap allocation, including any capacity prefix. Returns 0 when data is stored inline or not yet allocated.
insert Insert a value before a position by moving it.
insert Insert the elements of an initializer list before a position.
insert Insert a copy of a value before a position.
insert Insert n copies of a value before a position.
insert Insert a range of elements before a position.
operator[] Access the element at a given index, without bounds checking.
operator[] Access the element at a given index, without bounds checking.
pop_back Remove the last element.
push_back Append a copy of a value to the end.
push_back Append a value to the end by moving it.
rbegin Return a reverse iterator to the last element.
rbegin Return a const reverse iterator to the last element.
rend Return a reverse iterator past the first element.
rend Return a const reverse iterator past the first element.
reserve Ensure capacity for at least sz elements.
resize Change the number of elements, value-initializing any new elements.
resize Change the number of elements, copying a value into any new elements.
resize_without_initialization Grows without initializing the new elements. See folly::resizeWithoutInitialization.
shrink_to_fit Reduce heap capacity to fit the current size where possible.
size Return the number of elements.
swap Swap the contents of this small_vector with another.
operator== Test two small_vectors for equality.
operator< Compare two small_vectors lexicographically.

Static Member Functions

NameDescription
max_size Return the maximum number of elements the vector can hold.

Friends

NameDescription
folly::operator<=>Three-way compare two small_vectors lexicographically.

Non-Member Functions

NameDescription
eraseRemove all elements equal to a value from a small_vector.
erase_ifRemove all elements satisfying a predicate from a small_vector.
swapSwap the contents of two small_vectors.