vector.hpp
A drop-in wrapper for std::vector; adds on bounds checking in debug mode.
This class is a drop-in wrapper for std::vector, adding on bounds checking, both for the indexing operator and for the use of iterators (ensure that iterators do not outlive the version of vector for which it was created.) If EMP_NDEBUG is set then it reverts back to std::vector.
- Todo:
Debug code: member functions that take iterators should also take emp iterators that verify whether those iterators are valid.
Note
Status: BETA
Functions
-
template<typename T, typename ...Ts>
class vector : public std::vector<T, Ts...> - #include <type_traits.hpp>
Build a debug wrapper vector around std::vector.
Public Types
-
using iterator = iterator_wrapper<typename stdv_t::iterator>
-
using const_iterator = iterator_wrapper<typename stdv_t::const_iterator>
-
using reverse_iterator = iterator_wrapper<typename stdv_t::reverse_iterator>
-
using const_reverse_iterator = iterator_wrapper<typename stdv_t::const_reverse_iterator>
Public Functions
-
inline vector()
-
inline vector(size_t size)
-
inline ~vector()
-
inline size_t size() const
-
inline const_iterator begin() const noexcept
-
inline const_iterator end() const noexcept
-
inline const_iterator cbegin() const noexcept
-
inline const_iterator cend() const noexcept
-
inline reverse_iterator rbegin() noexcept
-
inline const_reverse_iterator rbegin() const noexcept
-
inline reverse_iterator rend() noexcept
-
inline const_reverse_iterator rend() const noexcept
-
inline const_reverse_iterator crbegin() const noexcept
-
inline const_reverse_iterator crend() const noexcept
-
inline void resize(size_t new_size)
-
inline void pop_back()
Public Members
-
int revision
Setup a revision number - iterators must match the revision of their vector.
Private Static Attributes
-
static constexpr const size_t MAX_SIZE = 2000000001
Setup a threshold; if we try to make a vector bigger than MAX_SIZE, throw a warning.
-
template<typename ITERATOR_T>
struct iterator_wrapper : public ITERATOR_T - #include <vector.hpp>
Setup an iterator wrapper to make sure that they’re not used again after a vector changes.
Public Functions
-
inline iterator_wrapper(const ITERATOR_T &_in, const vec_t *_v)
-
iterator_wrapper() = default
-
inline ~iterator_wrapper()
-
inline operator ITERATOR_T()
-
inline operator const ITERATOR_T() const
-
inline auto &operator*()
-
inline const auto &operator*() const
-
inline auto operator->()
-
inline auto operator->() const
-
inline auto operator+(int in)
-
inline auto operator-(int in)
-
inline auto &operator[](int offset)
Public Members
-
int revision
-
inline iterator_wrapper(const ITERATOR_T &_in, const vec_t *_v)
-
using iterator = iterator_wrapper<typename stdv_t::iterator>
-
template<typename t>
class vector<bool> - #include <vector.hpp>
Build a specialized debug wrapper for vector<bool>
Public Types
-
using value_type = bool
Public Functions
-
inline vector()
-
inline vector(size_t size)
-
inline vector(size_t size, bool val)
-
inline void resize(size_t new_size)
-
inline void resize(size_t new_size, bool val)
-
inline bool operator[](size_t pos) const
-
inline auto &back()
-
inline bool back() const
-
inline auto &front()
-
inline bool front() const
-
inline void pop_back()
Private Static Attributes
-
static constexpr const size_t MAX_SIZE = 2000000001
Setup a threshold; if we try to make a vector bigger than MAX_SIZE, throw a warning.
-
using value_type = bool