Dynamical System Framework
Loading...
Searching...
No Matches
dsf::PtrMapView< T > Class Template Reference

Non-owning view over a map of owning pointers, exposing (id, raw pointer) pairs. More...

#include <PtrMapView.hpp>

Inheritance diagram for dsf::PtrMapView< T >:

Classes

class  iterator
 Forward iterator returning (id, pointer) pairs by value. More...

Public Types

using map_type = std::unordered_map<Id, std::unique_ptr<std::remove_const_t<T>>>

Public Member Functions

 PtrMapView (map_type const &map) noexcept
iterator begin () const noexcept
iterator end () const noexcept
iterator cbegin () const noexcept
iterator cend () const noexcept
auto size () const noexcept
 Get the number of elements.
bool empty () const noexcept
 Check if the view is empty.
bool contains (Id const id) const
 Check if an element with the given id exists.
T & at (Id const id) const
 Get an element by id.

Detailed Description

template<typename T>
class dsf::PtrMapView< T >

Non-owning view over a map of owning pointers, exposing (id, raw pointer) pairs.

The view does not expose the std::unique_ptr, so callers cannot reset or release the owned objects. If T is const, the objects are only accessible as const. The iterators only wrap the map's iterators, so they stay valid after the view itself is destroyed.

Template Parameters
TThe type of the owned objects, optionally const-qualified

Member Function Documentation

◆ at()

template<typename T>
T & dsf::PtrMapView< T >::at ( Id const id) const
inline

Get an element by id.

Exceptions
std::out_of_rangeif no element with the given id exists

The documentation for this class was generated from the following file:
  • src/dsf/utility/PtrMapView.hpp