template class mrpt::containers::deep_const_iterator
Overview
Adapts a const_iterator of a container of smart pointers so that dereferencing it yields a shared_ptr<const T> instead of a shared_ptr<T>.
Containers of X::Ptr would otherwise let a const container hand out mutable pointees, defeating const-correctness. Note that, as with any proxy iterator, operator* returns by value, so use (*it)->method() and not it->method().
#include <mrpt/containers/deep_const_iterator.h> template <typename UNDERLYING_IT> class deep_const_iterator { public: // typedefs typedef typename underlying_ptr_t::element_type element_type; typedef std::shared_ptr<const element_type> value_type; typedef value_type reference; typedef void pointer; typedef std::ptrdiff_t difference_type; typedef std::bidirectional_iterator_tag iterator_category; // construction deep_const_iterator(); deep_const_iterator(const UNDERLYING_IT& it); // methods value_type operator * () const; deep_const_iterator& operator ++ (); deep_const_iterator operator ++ (int); deep_const_iterator& operator -- (); deep_const_iterator operator -- (int); bool operator == (const deep_const_iterator& o) const; bool operator != (const deep_const_iterator& o) const; const UNDERLYING_IT& underlying() const; };
Methods
const UNDERLYING_IT& underlying() const
Returns the wrapped underlying iterator.