Iterator¶
-
template<typename
T
, typenameinternal_container
, boolisConst
>
classrlogic
::
Iterator
¶ An STL-style iterator for various object types (T) with forward-semantics. See also:
Template parameters:
T: the object type to iterate over, e.g. rlogic::LuaScript
internal_container: the internally wrapped container type. User code should NOT depend on this type to avoid API incompatibilities!
isConst: true for const-iterators, false for non-const iterators
Dereferencing the iterator yields a pointer of type T* or const T*, depending if the iterator is a const iterator. The class is STL-compatible, meaning that the public type declarations may safely be used.
Additional note: the Iterator class does not support swap() functionality as well as mutable assignments, because the internal data structures used to iterate over objects are not supposed to be changed by user code. The iterators are supposed to be used only in read-only scenarios. It is still possible to exercise write access on the pointers returned by the iterator, but it’s not possible to assign a new value to the pointer itself or to swap the pointers.
Public Types
-
using
difference_type
= typename internal_iterator::difference_type¶ Type traits as mandated by STL for custom iterators.
-
using
value_type
= typename internal_iterator::value_type¶ The iterator type after dereferencing
Public Functions
-
maybe_const_T
operator*
() noexcept¶ Operator dereferencing. Returns const T* if template argument isConst == true, otherwise returns T*.
- Return
T* or const T* pointer to iterable object, depending on iterator constness
-
maybe_const_T
operator->
() noexcept¶ Member forwarding operator. Translates to ‘(const T*)->method’ if template argument isConst == true, otherwise to ‘(T*)->method’.
- Return
T* or const T* pointer to iterable object, depending on iterator constness
-
Iterator
operator++
(int) noexcept¶ Post-increment operator.
- Return
a copy of self before the increment was performed
-
template<bool
otherIsConst
>
booloperator==
(const Iterator<T, internal_container, otherIsConst> &other) const noexcept¶ Equality operator.
- Return
true if the iterators point to the same object internally
- Parameters
other
: the other iterator to compare to
-
template<bool
otherIsConst
>
booloperator!=
(const Iterator<T, internal_container, otherIsConst> &other) const noexcept¶ Inequality operator.
- Return
true if the iterators point to different objects internally
- Parameters
other
: the other iterator to compare to
-
Iterator
() noexcept = default¶ Default constructor.
-
template<bool
otherIsConst
, typename = std::enable_if_t<isConst && !otherIsConst>>Iterator
(const Iterator<T, internal_container, otherIsConst> &other) noexcept¶ Constructor which allows const-iterator to be constructed from a non-const iterator, but not the other way around
- Parameters
other
: iterator to construct from
-
template<bool
otherIsConst
, class = std::enable_if_t<isConst && !otherIsConst>>
Iterator &operator=
(const Iterator<T, internal_container, otherIsConst> &other) noexcept¶ Assignment operator which allows const-iterator to be assigned from a non-const iterator, but not the other way around
- Parameters
other
: iterator to be assign from
-
Iterator
(const Iterator&) noexcept = default¶ Default copy constructor. This is redundant to the template version above, but is considered good style.
-
Iterator &
operator=
(const Iterator&) noexcept = default¶ Default assignment operator. This is redundant to the template version above, but is considered good style.
-
~Iterator
() noexcept = default¶ Default destructor.
-
Iterator
(internal_iterator iter) noexcept¶ Internal constructor which should not be called by user code to avoid API dependencies. Use rlogic::Collection::begin() and rlogic::Collection::end() or their const-counterparts to obtain iterators to desired rlogic::LogicEngine objects.
- Parameters
iter
: internal iterator to be constructed from