template<typename T>
slang::SmallVectorBase class

Base class for a fast growable array.

SmallVector is a vector-like growable array that allocates its first N elements on the stack. As long as you don't need more room than that, there are no heap allocations – otherwise we spill over into the heap. This is the base class that erases the stack size template parameter for use with generic code.

Derived classes

template<typename T, size_t N = detail::calculateDefaultSmallVectorElems<T>()>
class SmallVector
A concrete, sized version of the SmallVectorBase<T> template.
template<typename T, size_t N = detail::calculateDefaultSmallVectorElems<T>()>
class SmallVector
A concrete, sized version of the SmallVectorBase<T> template.
template<typename T, size_t N = detail::calculateDefaultSmallVectorElems<T>()>
class SmallVector
A concrete, sized version of the SmallVectorBase<T> template.
template<typename T, size_t N = detail::calculateDefaultSmallVectorElems<T>()>
class SmallVector
A concrete, sized version of the SmallVectorBase<T> template.
template<typename T, size_t N = detail::calculateDefaultSmallVectorElems<T>()>
class SmallVector
A concrete, sized version of the SmallVectorBase<T> template.
template<typename T, size_t N = detail::calculateDefaultSmallVectorElems<T>()>
class SmallVector
A concrete, sized version of the SmallVectorBase<T> template.
template<typename T, size_t N = detail::calculateDefaultSmallVectorElems<T>()>
class SmallVector
A concrete, sized version of the SmallVectorBase<T> template.
template<typename T, size_t N = detail::calculateDefaultSmallVectorElems<T>()>
class SmallVector
A concrete, sized version of the SmallVectorBase<T> template.
template<typename T, size_t N = detail::calculateDefaultSmallVectorElems<T>()>
class SmallVector
A concrete, sized version of the SmallVectorBase<T> template.
template<typename T, size_t N = detail::calculateDefaultSmallVectorElems<T>()>
class SmallVector
A concrete, sized version of the SmallVectorBase<T> template.
template<typename T, size_t N = detail::calculateDefaultSmallVectorElems<T>()>
class SmallVector
A concrete, sized version of the SmallVectorBase<T> template.
template<typename T, size_t N = detail::calculateDefaultSmallVectorElems<T>()>
class SmallVector
A concrete, sized version of the SmallVectorBase<T> template.
template<typename T, size_t N = detail::calculateDefaultSmallVectorElems<T>()>
class SmallVector
A concrete, sized version of the SmallVectorBase<T> template.
template<typename T, size_t N = detail::calculateDefaultSmallVectorElems<T>()>
class SmallVector
A concrete, sized version of the SmallVectorBase<T> template.
template<typename T, size_t N = detail::calculateDefaultSmallVectorElems<T>()>
class SmallVector
A concrete, sized version of the SmallVectorBase<T> template.
template<typename T, size_t N = detail::calculateDefaultSmallVectorElems<T>()>
class SmallVector
A concrete, sized version of the SmallVectorBase<T> template.
template<typename T, size_t N = detail::calculateDefaultSmallVectorElems<T>()>
class SmallVector
A concrete, sized version of the SmallVectorBase<T> template.
template<typename T, size_t N = detail::calculateDefaultSmallVectorElems<T>()>
class SmallVector
A concrete, sized version of the SmallVectorBase<T> template.

Public functions

auto begin() -> iterator constexpr noexcept
auto end() -> iterator constexpr noexcept
auto begin() const -> const_iterator constexpr noexcept
auto end() const -> const_iterator constexpr noexcept
auto rbegin() -> reverse_iterator constexpr noexcept
auto rbegin() const -> const_reverse_iterator constexpr noexcept
auto rend() -> reverse_iterator constexpr noexcept
auto rend() const -> const_reverse_iterator constexpr noexcept
auto front() const -> const_reference constexpr
auto back() const -> const_reference constexpr
auto front() -> reference constexpr
auto back() -> reference constexpr
auto data() -> pointer constexpr noexcept
auto data() const -> const_pointer constexpr noexcept
auto size() const -> size_type constexpr noexcept
auto capacity() const -> size_type constexpr noexcept
auto max_size() const -> size_type constexpr noexcept
auto empty() const -> bool constexpr noexcept
void reserve(size_type newCapacity)
Ensures that there is enough allocated memory in the array for at least size objects.
void resize(size_type newSize)
Resizes the array.
void resize(size_t newSize, const T& value)
Resizes the array.
void resize_for_overwrite(size_type newSize)
Resizes the array.
void clear() noexcept
Clears all elements but retain underlying storage.
void pop_back()
Removes the last element from the array. The array must not be empty!
void push_back(const T& item)
Adds an element to the end of the array.
void push_back(T&& item)
Adds an element to the end of the array.
template<typename... Args>
auto emplace_back(Args && ... args) -> reference
Constructs a new element at the end of the array.
template<std::input_iterator TIter>
void append(TIter first, TIter last)
Appends a range of elements to the end of the array.
template<std::ranges::input_range TContainer>
void append_range(const TContainer& container)
Appends a range of elements to the end of the array.
void append(size_type count, const T& value)
Appends count copies of value to the end of the array.
void assign(size_type count, const T& value)
Resets the contents of the array to be count copies of value.
template<std::input_iterator TIter>
void assign(TIter first, TIter last)
Resets the contents of the array to be the contents of the given range.
template<std::ranges::input_range TContainer>
void assign_range(const TContainer& container)
Resets the contents of the array to be the contents of the given range.
template<typename... Args>
auto emplace(const_iterator pos, Args && ... args) -> iterator
Constructs a new element at the specified position in the array.
auto insert(const_iterator pos, const T& val) -> iterator
Inserts the given value at the specified position in the array.
auto insert(const_iterator pos, T&& val) -> iterator
Inserts the given value at the specified position in the array.
template<std::ranges::input_range TContainer>
auto insert_range(const_iterator pos, const TContainer& container) -> iterator
Inserts a range of elements at the specified position in the array.
template<std::input_iterator TIter>
auto insert(const_iterator pos, TIter first, TIter last) -> iterator
Inserts a range of elements at the specified position in the array.
auto insert(const_iterator pos, size_type count, const T& value) -> iterator
Inserts count copies of value at the specified position in the array.
auto erase(const_iterator pos) -> iterator
Removes the elements at pos from the array.
auto erase(const_iterator first, const_iterator last) -> iterator
Removes all elements between first and last from the array.
void swap(SmallVectorBase& rhs)
Swaps the contents of rhs with this array.
auto copy(BumpAllocator& alloc) const -> std::span<T>
Creates a copy of the array using the given allocator.
auto ccopy(BumpAllocator& alloc) const -> std::span<ConstElem>
Creates a constant copy of the array using the given allocator.
auto operator[](size_type index) -> reference constexpr
auto operator[](size_type index) const -> const_reference constexpr
auto at(size_type index) -> reference constexpr
auto at(size_type index) const -> const_reference constexpr
auto isSmall() const -> bool constexpr noexcept
Indicates whether we are still "small", which means we are still on the stack.

Function documentation

template<typename T>
iterator slang::SmallVectorBase<T>::begin() constexpr noexcept

Returns an iterator to the beginning of the array.

template<typename T>
iterator slang::SmallVectorBase<T>::end() constexpr noexcept

Returns an iterator to the end of the array.

template<typename T>
const_iterator slang::SmallVectorBase<T>::begin() const constexpr noexcept

Returns an iterator to the beginning of the array.

template<typename T>
const_iterator slang::SmallVectorBase<T>::end() const constexpr noexcept

Returns an iterator to the end of the array.

template<typename T>
reverse_iterator slang::SmallVectorBase<T>::rbegin() constexpr noexcept

Returns a reverse iterator to the end of the array.

template<typename T>
const_reverse_iterator slang::SmallVectorBase<T>::rbegin() const constexpr noexcept

Returns a reverse iterator to the end of the array.

template<typename T>
reverse_iterator slang::SmallVectorBase<T>::rend() constexpr noexcept

Returns a reverse iterator to the end of the array.

template<typename T>
const_reverse_iterator slang::SmallVectorBase<T>::rend() const constexpr noexcept

Returns a reverse iterator to the end of the array.

template<typename T>
const_reference slang::SmallVectorBase<T>::front() const constexpr

Returns a reference to the first element in the array. The array must not be empty!

template<typename T>
const_reference slang::SmallVectorBase<T>::back() const constexpr

Returns a reference to the last element in the array. The array must not be empty!

template<typename T>
reference slang::SmallVectorBase<T>::front() constexpr

Returns a reference to the first element in the array. The array must not be empty!

template<typename T>
reference slang::SmallVectorBase<T>::back() constexpr

Returns a reference to the last element in the array. The array must not be empty!

template<typename T>
pointer slang::SmallVectorBase<T>::data() constexpr noexcept

Returns a pointer to the underlying array.

template<typename T>
const_pointer slang::SmallVectorBase<T>::data() const constexpr noexcept

Returns a pointer to the underlying array.

template<typename T>
size_type slang::SmallVectorBase<T>::size() const constexpr noexcept

Returns the number of elements in the array.

template<typename T>
size_type slang::SmallVectorBase<T>::capacity() const constexpr noexcept

Returns the number of elements that can be held in currently allocated storage.

template<typename T>
size_type slang::SmallVectorBase<T>::max_size() const constexpr noexcept

Returns the maximum number of elements that could ever fit in the array, assuming the system had enough memory to support it.

template<typename T>
bool slang::SmallVectorBase<T>::empty() const constexpr noexcept

Returns true if the array is empty, and false if it has elements in it.

template<typename T>
void slang::SmallVectorBase<T>::resize(size_type newSize)

Resizes the array.

If larger than the current size, value constructs new elements to fill the gap. If smaller than the current size, the length is shrunk and elements are destructed.

template<typename T>
void slang::SmallVectorBase<T>::resize(size_t newSize, const T& value)

Resizes the array.

If larger than the current size, adds new elements as copies of value to fill the gap. If smaller than the current size, the length is shrunk and elements are destructed.

template<typename T>
void slang::SmallVectorBase<T>::resize_for_overwrite(size_type newSize)

Resizes the array.

If larger than the current size, default constructs new elements to fill the gap. If smaller than the current size, the length is shrunk and elements are destructed.

template<typename T>
std::span<ConstElem> slang::SmallVectorBase<T>::ccopy(BumpAllocator& alloc) const

Creates a constant copy of the array using the given allocator.

If the array holds pointers, const is added to the pointed-to type as well.

template<typename T>
reference slang::SmallVectorBase<T>::operator[](size_type index) constexpr

Returns the element at the given position in the array.

template<typename T>
const_reference slang::SmallVectorBase<T>::operator[](size_type index) const constexpr

Returns the element at the given position in the array.

template<typename T>
reference slang::SmallVectorBase<T>::at(size_type index) constexpr

Returns the element at the given position in the array.

template<typename T>
const_reference slang::SmallVectorBase<T>::at(size_type index) const constexpr

Returns the element at the given position in the array.