reference_vector.hpp

A version of vector that holds only references to objects. Be careful!

Note

Status: ALPHA

template<typename T>
class reference_vector
#include <reference_vector.hpp>

Public Functions

reference_vector() = default
reference_vector(const reference_vector&) = default
reference_vector(reference_vector&&) = default
inline ~reference_vector()
this_t &operator=(const reference_vector&) = default
this_t &operator=(reference_vector&&) = default
inline size_t size() const
inline void resize(size_t new_size)
inline T &operator[](size_t id)
inline const T &operator[](size_t id) const
inline void push_back(T &val)
inline Iterator begin()
inline const Iterator begin() const
inline Iterator end()
inline const Iterator end() const

Private Types

using this_t = reference_vector<T>
using vec_t = vector<Ptr<T>>
using iterator_t = Iterator

Private Members

vec_t vals
class Iterator

Public Functions

inline Iterator(this_t &v, size_t pos = 0)
inline Iterator(const typename vec_t::iterator &in_it)
Iterator(const Iterator&) = default
Iterator &operator=(const Iterator&) = default
inline Iterator &operator++()
inline Iterator &operator--()
inline bool operator==(const Iterator &in) const

Iterator comparisons.

inline bool operator!=(const Iterator &in) const
inline bool operator<(const Iterator &in) const
inline bool operator<=(const Iterator &in) const
inline bool operator>(const Iterator &in) const
inline bool operator>=(const Iterator &in) const
inline T &operator*()

Return a reference to the element pointed to by this iterator; may advance iterator.

inline const T &operator*() const

Return a const reference to the element pointed to by this iterator.

inline operator bool() const

Is this iterator pointing to a valid position in the vector?

inline Iterator begin()

Return an iterator pointing to the first position in the vector.

inline const Iterator begin() const

Return a const iterator pointing to the first position in the vector.

inline Iterator end()

Return an iterator pointing to just past the end of the vector.

inline const Iterator end() const

Return a const iterator pointing to just past the end of the vector.

Private Members

vec_t::iterator it

Todo:

Add a const interator, and probably a reverse iterator.