31#include "neml2/misc/error.h"
43template <
typename I,
typename T>
55 template <
class BaseIterator>
63 using key_type =
typename BaseIterator::value_type::first_type;
64 using value_type =
typename BaseIterator::value_type::second_type::element_type;
68 auto & [
key,
val] = BaseIterator::operator*();
70 "Trying to dereference a null object. Make sure the storage was properly "
71 "initialized using set_pointer().");
76 auto & [
key,
val] = BaseIterator::operator*();
78 "Trying to dereference a null object. Make sure the storage was properly "
79 "initialized using set_pointer().");
115 "Trying to access a null object. Make sure the storage was properly "
116 "initialized using set_pointer().");
117 return *pointer_value(
i);
128 std::size_t
size()
const {
return _values.size(); }
133 bool empty()
const {
return _values.empty(); }
150 return has_key(
i) ?
const_cast<T *
>(std::as_const(*this).query_value(
i)) :
nullptr;
165 _values[
i] = std::move(
ptr);
166 return _values[
i].get();
177 const std::unique_ptr<T> & pointer_value(
const I &
i)
const {
return _values.at(
i); }
The wrapper (decorator) for cross-referencing unresolved values at parse time.
Definition CrossRef.h:52
Storage(const Storage &)=delete
const_iterator begin() const
Definition Storage.h:98
T & operator[](const I &i) const
Definition Storage.h:112
T & operator[](const I &i)
Definition Storage.h:119
DereferenceIterator< typename values_type::const_iterator > const_iterator
Definition Storage.h:86
bool empty() const
Definition Storage.h:133
Storage & operator=(const Storage &)=delete
const T * query_value(const I &i) const
Definition Storage.h:147
T * query_value(const I &i)
Definition Storage.h:148
typename std::map< I, std::unique_ptr< T > > values_type
Definition Storage.h:84
T * set_pointer(const I &i, std::unique_ptr< T > &&ptr)
Definition Storage.h:163
bool has_key(const I &i) const
Definition Storage.h:138
DereferenceIterator< typename values_type::iterator > iterator
Definition Storage.h:85
iterator end()
Definition Storage.h:97
const_iterator end() const
Definition Storage.h:99
iterator begin()
Definition Storage.h:96
std::size_t size() const
Definition Storage.h:128
Storage(Storage &&)=default
Definition CrossRef.cxx:32
void neml_assert_dbg(bool assertion, Args &&... args)
Definition error.h:85
typename BaseIterator::value_type::first_type key_type
Definition Storage.h:63
typename BaseIterator::value_type::second_type::element_type value_type
Definition Storage.h:64
std::pair< key_type, value_type & > operator*() const
Definition Storage.h:66
std::pair< key_type, value_type * > operator->() const
Definition Storage.h:74
DereferenceIterator(const BaseIterator &it)
Definition Storage.h:58