31#include "neml2/misc/error.h"
43template <
typename I,
typename T>
52 template <
class BaseIterator>
60 using key_type =
typename BaseIterator::value_type::first_type;
61 using value_type =
typename BaseIterator::value_type::second_type::element_type;
65 auto & [
key,
val] = BaseIterator::operator*();
67 "Trying to dereference a null object. Make sure the storage was properly "
68 "initialized using set_pointer().");
73 auto & [
key,
val] = BaseIterator::operator*();
75 "Trying to dereference a null object. Make sure the storage was properly "
76 "initialized using set_pointer().");
113 "Trying to access a non-existent value with name '" +
utils::stringify(
i) +
"'.");
114 return *pointer_value(
i);
125 std::size_t
size()
const {
return _values.size(); }
130 bool empty()
const {
return _values.empty(); }
148 return has_key(
i) ?
const_cast<T *
>(std::as_const(*this).query_value(
i)) :
nullptr;
163 _values[
i] = std::move(
ptr);
164 return _values[
i].get();
175 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:54
const_iterator begin() const
Definition Storage.h:96
T & operator[](const I &i) const
Definition Storage.h:110
T & operator[](const I &i)
Definition Storage.h:116
DereferenceIterator< typename values_type::const_iterator > const_iterator
Definition Storage.h:83
bool empty() const
Definition Storage.h:130
const T * query_value(const I &i) const
Definition Storage.h:144
T * query_value(const I &i)
Definition Storage.h:145
typename std::map< I, std::unique_ptr< T > > values_type
Definition Storage.h:81
T * set_pointer(const I &i, std::unique_ptr< T > &&ptr)
Definition Storage.h:161
bool has_key(const I &i) const
Definition Storage.h:135
DereferenceIterator< typename values_type::iterator > iterator
Definition Storage.h:82
iterator end()
Definition Storage.h:95
const_iterator end() const
Definition Storage.h:97
iterator begin()
Definition Storage.h:94
std::size_t size() const
Definition Storage.h:125
std::string stringify(const T &t)
Definition utils.h:317
Definition CrossRef.cxx:31
void neml_assert_dbg(bool assertion, Args &&... args)
Definition error.h:76
void neml_assert(bool assertion, Args &&... args)
Definition error.h:64
typename BaseIterator::value_type::first_type key_type
Definition Storage.h:60
typename BaseIterator::value_type::second_type::element_type value_type
Definition Storage.h:61
std::pair< key_type, value_type & > operator*() const
Definition Storage.h:63
std::pair< key_type, value_type * > operator->() const
Definition Storage.h:71
DereferenceIterator(const BaseIterator &it)
Definition Storage.h:55