9template <
typename element_type>
12template <
typename element_type>
25template <
typename element_type>
29 std::shared_ptr<internal::life_validator> validator_;
32 const std::string *type_name_;
33 const std::string &type_name()
const {
38 element_type *assert_iter(
const std::string &func,
43 assert_iter_including_end(
const std::string &func,
47 void update_iter(
const std::string &func,
49 validator_->ptr_ = this->ptr_;
50 if (!validator_->valid_) {
56 if (ptr_ > observer_.
end()) {
59 if (ptr_ < observer_.
begin()) {
66 const std::string *type_name) noexcept
67 : ptr_(
ptr), observer_(observer),
68 validator_(observer.push_validator(
69 std::make_shared<life_validator>(
ptr ))),
70 life_(
this), type_name_(type_name) {}
72 const std::string *type_name,
bool valid,
74 : ptr_(
ptr), observer_(observer),
75 validator_(observer.push_validator(
77 life_(this), type_name_(type_name) {
81 template <
typename T,
typename std::enable_if<
82 std::is_same<const T, element_type>::value,
83 std::nullptr_t>::type =
nullptr>
85 : ptr_(other.ptr_), observer_(other.observer_),
86 validator_(observer_.push_validator(
88 life_(this), type_name_(other.type_name_) {}
91 : ptr_(other.ptr_), observer_(other.observer_),
92 validator_(observer_.push_validator(
94 life_(this), type_name_(other.type_name_) {}
97 observer_ = other.observer_;
99 std::make_shared<life_validator>(*other.validator_));
100 type_name_ = other.type_name_;
105 template <
typename T>
109 friend element_type *y3c::internal::unwrap<>(
118 template <
typename =
internal::skip_trace_tag>
120 std::string func = type_name() +
"::operator*()";
121 return reference(assert_iter(func), observer_);
123 template <
typename =
internal::skip_trace_tag>
125 std::string func = type_name() +
"::operator->()";
126 return assert_iter(func);
129 template <
typename =
internal::skip_trace_tag>
132 update_iter(type_name() +
"::operator++()");
135 template <
typename =
internal::skip_trace_tag>
139 update_iter(type_name() +
"::operator++()");
142 template <
typename =
internal::skip_trace_tag>
145 update_iter(type_name() +
"::operator--()");
148 template <
typename =
internal::skip_trace_tag>
152 update_iter(type_name() +
"::operator--()");
155 template <
typename =
internal::skip_trace_tag>
158 update_iter(type_name() +
"::operator+=()");
161 template <
typename =
internal::skip_trace_tag>
164 update_iter(type_name() +
"::operator-=()");
167 template <
typename =
internal::skip_trace_tag>
170 this->validator_->valid_,
171 type_name() +
"::operator+()");
173 template <
typename =
internal::skip_trace_tag>
176 this->validator_->valid_,
177 type_name() +
"::operator-()");
181 return ptr_ - other.ptr_;
183 template <
typename =
internal::skip_trace_tag>
185 static std::string func = type_name() +
"::operator[]()";
188 this->validator_->valid_, func)
207template <
typename element_type>
246template <
typename element_type>
array, vector など各種コンテナのイテレータ
Definition iterator.h:26
contiguous_iterator(element_type *ptr, internal::life_observer observer, const std::string *type_name, bool valid, const std::string &func, internal::skip_trace_tag={})
Definition iterator.h:71
friend class contiguous_iterator
Definition iterator.h:106
contiguous_iterator operator-(std::ptrdiff_t n) const
Definition iterator.h:174
reference operator[](std::ptrdiff_t n) const
Definition iterator.h:184
contiguous_iterator(element_type *ptr, internal::life_observer observer, const std::string *type_name) noexcept
Definition iterator.h:65
contiguous_iterator(const contiguous_iterator &other)
Definition iterator.h:90
contiguous_iterator & operator++()
Definition iterator.h:130
contiguous_iterator operator+(std::ptrdiff_t n) const
Definition iterator.h:168
contiguous_iterator operator++(int)
Definition iterator.h:136
std::ptrdiff_t operator-(const contiguous_iterator &other) const noexcept
Definition iterator.h:180
contiguous_iterator & operator=(const contiguous_iterator &other)
Definition iterator.h:95
std::random_access_iterator_tag iterator_category
Definition iterator.h:116
contiguous_iterator & operator--()
Definition iterator.h:143
wrap< contiguous_iterator * > operator&()
Definition iterator.h:199
wrap_ref< element_type > reference
Definition iterator.h:115
contiguous_iterator & operator-=(std::ptrdiff_t n)
Definition iterator.h:162
element_type * operator->() const
Definition iterator.h:124
element_type value_type
Definition iterator.h:113
contiguous_iterator(const contiguous_iterator< T > &other)
Definition iterator.h:84
wrap< const contiguous_iterator * > operator&() const
Definition iterator.h:202
std::ptrdiff_t difference_type
Definition iterator.h:112
contiguous_iterator operator--(int)
Definition iterator.h:149
reference operator*() const
Definition iterator.h:119
~contiguous_iterator()=default
const life_observer & get_observer_() const
Definition iterator.h:108
element_type * pointer
Definition iterator.h:114
contiguous_iterator & operator+=(std::ptrdiff_t n)
Definition iterator.h:156
ライフタイムの状態を観測するクラス
Definition life.h:89
element_type * assert_iter_including_end(const contiguous_iterator< element_type > &iter, const std::string &func, internal::skip_trace_tag={}) const
Definition life.h:152
const void * end() const
Definition life.h:111
element_type * assert_iter(const contiguous_iterator< element_type > &iter, const std::string &func, internal::skip_trace_tag={}) const
Definition life.h:130
const void * begin() const
Definition life.h:110
const std::shared_ptr< life_validator > & push_validator(const std::shared_ptr< life_validator > &v) const
Definition life.h:106
オブジェクトのライフタイムを管理するクラス
Definition life.h:207
life_observer observer() const
Definition life.h:233
ポインタ型wrap: element_type型のデータへのポインタと、 このポインタ自体の生存状態を管理するクラス
Definition wrap.h:318
参照型wrap: element_type型のデータへの参照を持つクラス
Definition wrap.h:168
値型wrap: base_type型のデータと、このデータの生存状態を管理するクラス
Definition wrap.h:26
element_type * unwrap(const contiguous_iterator< element_type > &wrapper) noexcept
Definition iterator.h:209
bool operator>(const contiguous_iterator< T > &lhs, const contiguous_iterator< T > &rhs)
Definition iterator.h:230
bool operator!=(const contiguous_iterator< T > &lhs, const contiguous_iterator< T > &rhs)
Definition iterator.h:220
void terminate_ub_iter_before_begin(std::string func, Args &&...args)
Definition terminate.h:138
void terminate_ub_iter_after_end(std::string func, Args &&...args)
Definition terminate.h:137
bool operator>=(const contiguous_iterator< T > &lhs, const contiguous_iterator< T > &rhs)
Definition iterator.h:240
bool operator<=(const contiguous_iterator< T > &lhs, const contiguous_iterator< T > &rhs)
Definition iterator.h:235
bool operator==(const contiguous_iterator< T > &lhs, const contiguous_iterator< T > &rhs)
Definition iterator.h:215
void terminate_ub_invalid_iter(std::string func, Args &&...args)
Definition terminate.h:136
bool operator<(const contiguous_iterator< T > &lhs, const contiguous_iterator< T > &rhs)
Definition iterator.h:225
shared_ptr< T > make_shared(Args &&...args)
shared_ptrを構築する
Definition shared_ptr.h:298
std::array< T, N > & unwrap(array< T, N > &wrapper) noexcept
Definition array.h:372
Definition terminate.h:27