Template Class SmallVector

Inheritance Relationships

Base Types

Class Documentation

template<typename T, unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
class SmallVector : public ams::SmallVectorImpl<T>, private ams::SmallVectorStorage<T, CalculateSmallVectorDefaultInlinedElements<T>::value>

Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference sizeof(SmallVector<T, 0>).

This is a ‘vector’ (really, 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.

Note

In the absence of a well-motivated choice for the number of inlined elements N, it is recommended to use SmallVector<T> (that is, omitting the N). This will choose a default number of inlined elements reasonable for allocation on the stack (for example, trying to keep sizeof(SmallVector<T>) around 64 bytes).

Warning

This does not attempt to be exception safe.

Public Functions

inline SmallVector()
inline ~SmallVector()
inline explicit SmallVector(size_t Size)
inline SmallVector(size_t Size, const T &Value)
template<typename ItTy, typename = EnableIfConvertibleToInputIterator<ItTy>>
inline SmallVector(ItTy S, ItTy E)
template<typename RangeTy>
inline explicit SmallVector(const iterator_range<RangeTy> &R)
inline SmallVector(std::initializer_list<T> IL)
template<typename U, typename = std::enable_if_t<std::is_convertible<U, T>::value>>
inline explicit SmallVector(ArrayRef<U> A)
inline SmallVector(const SmallVector &RHS)
inline SmallVector &operator=(const SmallVector &RHS)
inline SmallVector(SmallVector &&RHS)
inline SmallVector(SmallVectorImpl<T> &&RHS)
inline SmallVector &operator=(SmallVector &&RHS)
inline SmallVector &operator=(SmallVectorImpl<T> &&RHS)
inline SmallVector &operator=(std::initializer_list<T> IL)