Template Class SmallVector

Class Documentation

template<class T, std::size_t N = 8>
class SmallVector

a vector with room for N items inside itself

Public Types

using value_type = T
using size_type = std::size_t
using difference_type = std::ptrdiff_t
using reference = T&
using const_reference = const T&
using pointer = T*
using const_pointer = const T*
using iterator = T*
using const_iterator = const T*
using reverse_iterator = std::reverse_iterator<iterator>
using const_reverse_iterator = std::reverse_iterator<const_iterator>

Public Functions

inline SmallVector(void) noexcept
explicit SmallVector(std::size_t n, const T &x = T())

n items made from x

SmallVector(std::initializer_list<T> items)
template<std::input_iterator I, std::sentinel_for<I> S>
SmallVector(I first, S last)

the items of [ first , last ), in their order

SmallVector(const SmallVector &other)
SmallVector(SmallVector &&other) noexcept(std::is_nothrow_move_constructible_v<T>)

the items of other, which is left empty

SmallVector &operator=(const SmallVector &other)
SmallVector &operator=(SmallVector &&other) noexcept(std::is_nothrow_move_constructible_v<T>)
~SmallVector()
void swap(SmallVector &other)
inline bool empty(void) const
inline std::size_t size(void) const
inline std::size_t capacity(void) const
inline bool small(void) const

the items are inside the vector

inline T *data(void)
inline const T *data(void) const
inline iterator begin(void)
inline iterator end(void)
inline const_iterator begin(void) const
inline const_iterator end(void) const
inline const_iterator cbegin(void) const
inline const_iterator cend(void) const
inline reverse_iterator rbegin(void)
inline reverse_iterator rend(void)
inline const_reverse_iterator rbegin(void) const
inline const_reverse_iterator rend(void) const
inline T &operator[](std::size_t i)
Pre:

i < size()

inline const T &operator[](std::size_t i) const
inline T &front(void)
Pre:

the vector is not empty

inline const T &front(void) const
inline T &back(void)
inline const T &back(void) const
inline void push_back(const T &x)

x at the end, O( 1 ) amortized; x may be an item of the vector

inline void push_back(T &&x)
template<class ...Args>
T &emplace_back(Args&&... args)

an item made from the arguments at the end, which may refer to items of the vector

void pop_back(void)
Pre:

the vector is not empty

void reserve(std::size_t n)

room for n items

void resize(std::size_t n, const T &x = T())

n items, those added made from x

void clear(void)

removes the items, keeping the memory

inline bool operator==(const SmallVector &o) const