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().");
116 "Trying to access a null object. Make sure the storage was properly "
117 "initialized using set_pointer().");
118 return *pointer_value(
i);
129 std::size_t
size()
const {
return _values.size(); }
134 bool empty()
const {
return _values.empty(); }
151 return has_key(
i) ?
const_cast<T *
>(std::as_const(*this).query_value(
i)) :
nullptr;
166 _values[
i] = std::move(
ptr);
167 return _values[
i].get();
178 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:56
Storage(const Storage &)=delete
const_iterator begin() const
Definition Storage.h:99
T & operator[](const I &i) const
Definition Storage.h:113
T & operator[](const I &i)
Definition Storage.h:120
DereferenceIterator< typename values_type::const_iterator > const_iterator
Definition Storage.h:86
bool empty() const
Definition Storage.h:134
Storage & operator=(const Storage &)=delete
const T * query_value(const I &i) const
Definition Storage.h:148
T * query_value(const I &i)
Definition Storage.h:149
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:164
bool has_key(const I &i) const
Definition Storage.h:139
DereferenceIterator< typename values_type::iterator > iterator
Definition Storage.h:85
iterator end()
Definition Storage.h:98
const_iterator end() const
Definition Storage.h:100
iterator begin()
Definition Storage.h:97
std::size_t size() const
Definition Storage.h:129
Storage(Storage &&)=default
Definition CrossRef.cxx:30
void neml_assert_dbg(bool assertion, Args &&... args)
Definition error.h:76
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