C/C++ API Reference
Loading...
Searching...
No Matches
pw::DynamicPtrVector< T, SizeType > Class Template Reference

Overview

template<typename T, typename SizeType = uint16_t>
class pw::DynamicPtrVector< T, SizeType >

A std::vector-like container that holds pointers to objects of type T.

DynamicPtrVector allocates objects using a pw::Allocator and stores pointers to them. This allows storing objects that are not movable or copyable, or objects of polymorphic types, while still providing a vector-like interface.

The interface mirrors std::vector<T>, but the underlying storage is DynamicVector<T*>.

Public Types

using value_type = T
 
using size_type = SizeType
 
using difference_type = std::ptrdiff_t
 
using reference = value_type &
 
using const_reference = const value_type &
 
using pointer = value_type *
 
using const_pointer = const value_type *
 
using allocator_type = Allocator
 
using iterator = Iterator< false >
 
using const_iterator = Iterator< true >
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 

Public Member Functions

constexpr DynamicPtrVector (Allocator &allocator)
 Constructs an empty DynamicPtrVector using the provided allocator.
 
 DynamicPtrVector (const DynamicPtrVector &)=delete
 
DynamicPtrVectoroperator= (const DynamicPtrVector &)=delete
 
 DynamicPtrVector (DynamicPtrVector &&other) noexcept=default
 
DynamicPtrVectoroperator= (DynamicPtrVector &&other) noexcept
 
iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
iterator end ()
 
const_iterator end () const
 
const_iterator cend () const
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator crbegin () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
const_reverse_iterator crend () const
 
allocator_typeget_allocator () const
 
bool empty () const
 
size_type size () const
 
size_type ptr_capacity () const
 
size_type max_size () const
 
void reserve_ptr (size_type new_capacity)
 
void reserve_ptr_exact (size_type new_capacity)
 
bool try_reserve_ptr (size_type new_capacity)
 
bool try_reserve_ptr_exact (size_type new_capacity)
 
void shrink_to_fit ()
 
reference operator[] (size_type pos)
 
const_reference operator[] (size_type pos) const
 
reference at (size_type pos)
 
const_reference at (size_type pos) const
 
reference front ()
 
const_reference front () const
 
reference back ()
 
const_reference back () const
 
T *const * data ()
 
const T *const * data () const
 
void push_back (const T &value)
 Appends a new element by copying value.
 
void push_back (T &&value)
 Appends a new element by moving value.
 
bool try_push_back (const T &value)
 Attempts to append a new element by copying value.
 
bool try_push_back (T &&value)
 Attempts to append a new element by moving value.
 
void pop_back ()
 
pw::UniquePtr< T > take (const_iterator pos)
 Removes the element at pos and returns it as a UniquePtr.
 
template<typename U = T, typename... Args>
void emplace_back (Args &&... args)
 
template<typename U = T, typename... Args>
bool try_emplace_back (Args &&... args)
 
template<typename U = T, typename... Args>
iterator emplace (const_iterator pos, Args &&... args)
 
template<typename U = T, typename... Args>
std::optional< iterator > try_emplace (const_iterator pos, Args &&... args)
 
iterator insert (const_iterator pos, const T &value)
 
iterator insert (const_iterator pos, T &&value)
 
std::optional< iterator > try_insert (const_iterator pos, const T &value)
 
std::optional< iterator > try_insert (const_iterator pos, T &&value)
 
iterator erase (const_iterator pos)
 
iterator erase (const_iterator first, const_iterator last)
 
void clear ()
 

The documentation for this class was generated from the following file: