template<typename T, unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
Death::Containers::SmallVector class

Memory-optimized vector.

Template parameters
T Element type
N Number of in-place elements

A variable-sized array optimized for the case when the array is small. It contains some number of elements in-place, which allows it to avoid heap allocation when the actual number of elements is below that threshold. This allows normal "small" cases to be fast without losing generality for large inputs.

Base classes

template<typename T>
class SmallVectorImpl<T>
Common method implementations of SmallVector class to reduce code duplication based on N template parameter.

Constructors, destructors, conversion operators

SmallVector()
Default constructor.
SmallVector(DefaultInitT, std::size_t size) explicit
Construct a default-initialized vector.
SmallVector(ValueInitT, std::size_t size) explicit
Construct a value-initialized vector.
SmallVector(InPlaceInitT, ArrayView<const T> list)
Construct a list-initialized vector.
template<typename ItTy, std::enable_if_t<std::is_convertible<typename std::iterator_traits<ItTy>::iterator_category, std::input_iterator_tag>::value, int> = 0>
SmallVector(InPlaceInitT, ItTy s, ItTy e)
SmallVector(InPlaceInitT, std::initializer_list<T> il)
SmallVector(std::size_t size) explicit
Construct a value-initialized vector.
SmallVector(const SmallVector& other)
Copy constructor.
SmallVector(SmallVector&& other)
Move constructor.
SmallVector(SmallVectorImpl<T>&& other)
~SmallVector()
Destructor.

Public functions

auto operator=(const SmallVector& other) -> SmallVector&
Copy assignment.
auto operator=(std::initializer_list<T> il) -> SmallVector&
auto operator=(SmallVector&& other) -> SmallVector&
Move assignment.
auto operator=(SmallVectorImpl<T>&& other) -> SmallVector&
auto size() const -> std::size_t
Returns the number of elements.
auto capacity() const -> std::size_t
Returns the number of elements that can be held in currently allocated storage.
auto empty() const -> bool
Returns whether the container is empty.
auto begin() -> iterator
Returns an iterator to the beginning.
auto begin() const -> const_iterator
auto end() -> iterator
Returns an iterator to the end.
auto end() const -> const_iterator
auto rbegin() -> reverse_iterator
Returns a reverse iterator to the beginning.
auto rbegin() const -> const_reverse_iterator
auto rend() -> reverse_iterator
Returns a reverse iterator to the end.
auto rend() const -> const_reverse_iterator
auto size_in_bytes() const -> size_type
Returns total size in bytes.
auto max_size() const -> size_type
Returns maximum number of elements.
auto capacity_in_bytes() const -> std::size_t
Returns capacity in bytes.
auto data() -> pointer
Returns a pointer to the vector's buffer.
auto data() const -> const_pointer
auto operator[](size_type idx) -> reference
Access specified element.
auto operator[](size_type idx) const -> const_reference
auto front() -> reference
Access the first element.
auto front() const -> const_reference
auto back() -> reference
Access the last element.
auto back() const -> const_reference
void clear()
Clears the vector.
void resize(size_type n)
Resizes the vector to given size, value-initializing new elements.
void resize(size_type n, ValueParamT nv)
Resizes the vector to given size, constructing new elements using provided argument.
void resize_for_overwrite(size_type n)
Resizes the vector to given size, default-initializing new elements.
void truncate(size_type n)
Like resize, but requires that n is less than size()
void reserve(size_type n)
Reserve given capacity in the vector.
void push_back(const T& elt)
Adds an element to the end.
void push_back(T&& elt)
void pop_back()
Removes the last element.
void pop_back_n(size_type n)
Removes the last n elements.
auto pop_back_val() -> T
Removes the last element and returns it.
void swap(SmallVectorImpl& other)
Swaps the contents.
template<typename in_iter, std::enable_if_t<std::is_convertible<typename std::iterator_traits<in_iter>::iterator_category, std::input_iterator_tag>::value, int> = 0>
void append(in_iter inStart, in_iter inEnd)
Adds the specified range to the end of the vector.
void append(size_type n, ValueParamT elt)
Appends n copies of elt to the end.
void append(std::initializer_list<T> il)
Appends the specified list to the end.
void append(const SmallVectorImpl& other)
Appends the specified vector to the end.
void assign(size_type n, ValueParamT elt)
Assigns n copies of elt.
template<typename in_iter, std::enable_if_t<std::is_convertible<typename std::iterator_traits<in_iter>::iterator_category, std::input_iterator_tag>::value, int> = 0>
void assign(in_iter inStart, in_iter inEnd)
Assigns the specified range.
void assign(std::initializer_list<T> il)
Assigns the specified list.
void assign(const SmallVectorImpl& other)
Assigns the specified vector.
auto erase(const_iterator ci) -> iterator
Removes elements from the vector.
auto erase(const_iterator cs, const_iterator ce) -> iterator
void erase(size_type index)
auto eraseUnordered(const_iterator ci) -> iterator
Removes an element from the unordered vector.
void eraseUnordered(size_type index)
auto insert(iterator i, T&& elt) -> iterator
Inserts elements.
auto insert(iterator i, const T& elt) -> iterator
auto insert(iterator i, size_type numToInsert, ValueParamT elt) -> iterator
template<typename ItTy, std::enable_if_t<std::is_convertible<typename std::iterator_traits<ItTy>::iterator_category, std::input_iterator_tag>::value, int> = 0>
auto insert(iterator i, ItTy from, ItTy to) -> iterator
void insert(iterator i, std::initializer_list<T> il)

Function documentation

template<typename T, unsigned N>
Death::Containers::SmallVector<T, N>::SmallVector(DefaultInitT, std::size_t size) explicit

Construct a default-initialized vector.

Creates a vector of given size, the contents are default-initialized (i.e. trivial types are not initialized, default constructor called otherwise). If the size is zero, no allocation is done.

template<typename T, unsigned N>
Death::Containers::SmallVector<T, N>::SmallVector(ValueInitT, std::size_t size) explicit

Construct a value-initialized vector.

Creates a vector of given size, the contents are value-initialized (i.e. trivial types are zero-initialized, default constructor called otherwise). This is the same as SmallVector(std::size_t). If the size is zero, no allocation is done.

template<typename T, unsigned N>
Death::Containers::SmallVector<T, N>::SmallVector(InPlaceInitT, ArrayView<const T> list)

Construct a list-initialized vector.

Copy-initializes each element with placement new using values from list.

template<typename T, unsigned N> template<typename ItTy, std::enable_if_t<std::is_convertible<typename std::iterator_traits<ItTy>::iterator_category, std::input_iterator_tag>::value, int> = 0>
Death::Containers::SmallVector<T, N>::SmallVector(InPlaceInitT, ItTy s, ItTy e)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
Death::Containers::SmallVector<T, N>::SmallVector(InPlaceInitT, std::initializer_list<T> il)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
Death::Containers::SmallVector<T, N>::SmallVector(std::size_t size) explicit

Construct a value-initialized vector.

Alias to SmallVector(ValueInitT, std::size_t).

template<typename T, unsigned N>
Death::Containers::SmallVector<T, N>::SmallVector(SmallVectorImpl<T>&& other)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
SmallVector& Death::Containers::SmallVector<T, N>::operator=(std::initializer_list<T> il)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
SmallVector& Death::Containers::SmallVector<T, N>::operator=(SmallVectorImpl<T>&& other)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
const_iterator Death::Containers::SmallVector<T, N>::begin() const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
const_iterator Death::Containers::SmallVector<T, N>::end() const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
const_reverse_iterator Death::Containers::SmallVector<T, N>::rbegin() const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
const_reverse_iterator Death::Containers::SmallVector<T, N>::rend() const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
const_pointer Death::Containers::SmallVector<T, N>::data() const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
const_reference Death::Containers::SmallVector<T, N>::operator[](size_type idx) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
const_reference Death::Containers::SmallVector<T, N>::front() const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
const_reference Death::Containers::SmallVector<T, N>::back() const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
void Death::Containers::SmallVector<T, N>::push_back(T&& elt)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
iterator Death::Containers::SmallVector<T, N>::erase(const_iterator cs, const_iterator ce)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
void Death::Containers::SmallVector<T, N>::erase(size_type index)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
void Death::Containers::SmallVector<T, N>::eraseUnordered(size_type index)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
iterator Death::Containers::SmallVector<T, N>::insert(iterator i, const T& elt)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
iterator Death::Containers::SmallVector<T, N>::insert(iterator i, size_type numToInsert, ValueParamT elt)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N> template<typename ItTy, std::enable_if_t<std::is_convertible<typename std::iterator_traits<ItTy>::iterator_category, std::input_iterator_tag>::value, int> = 0>
iterator Death::Containers::SmallVector<T, N>::insert(iterator i, ItTy from, ItTy to)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T, unsigned N>
void Death::Containers::SmallVector<T, N>::insert(iterator i, std::initializer_list<T> il)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.