MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / iterator

Class iterator

example/cacheHierarchy/fkYAML/node.hpp:9983–10285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9981/// @tparam ValueType The type of iterated elements.
9982template <typename ValueType>
9983class iterator {
9984 /// @brief The iterator type with ValueType of different const-ness.
9985 using other_iterator_type = typename std::conditional<
9986 std::is_const<ValueType>::value, iterator<typename std::remove_const<ValueType>::type>,
9987 iterator<const ValueType>>::type;
9988
9989 friend other_iterator_type;
9990
9991public:
9992 /// A type for iterator traits of instantiated @Iterator template class.
9993 using iterator_traits_type = iterator_traits<ValueType>;
9994
9995 /// A type for iterator category tag.
9996 using iterator_category = std::bidirectional_iterator_tag;
9997 /// A type of iterated element.
9998 using value_type = typename iterator_traits_type::value_type;
9999 /// A type to represent differences between iterators.
10000 using difference_type = typename iterator_traits_type::difference_type;
10001 /// A type of an element pointer.
10002 using pointer = typename iterator_traits_type::pointer;
10003 /// A type of reference to an element.
10004 using reference = typename iterator_traits_type::reference;
10005
10006 static_assert(is_basic_node<value_type>::value, "iterator class only accepts a basic_node as its value type.");
10007
10008 /// @brief Constructs an iterator object.
10009 iterator() = default;
10010
10011 /// @brief Construct a new iterator object with sequence iterator object.
10012 /// @param[in] itr An sequence iterator object.
10013 iterator(const typename value_type::sequence_type::iterator& itr) noexcept {
10014 m_iterator_holder.sequence_iterator = itr;
10015 }
10016
10017 /// @brief Construct a new iterator object with mapping iterator object.
10018 /// @param[in] itr An mapping iterator object.
10019 iterator(const typename value_type::mapping_type::iterator& itr) noexcept
10020 : m_inner_iterator_type(iterator_t::MAPPING) {
10021 m_iterator_holder.mapping_iterator = itr;
10022 }
10023
10024 /// @brief Copy constructs an iterator.
10025 iterator(const iterator&) = default;
10026
10027 /// @brief Copy constructs an iterator from another iterator with different const-ness in ValueType.
10028 /// @note This copy constructor is not defined if ValueType is not const to avoid const removal from ValueType.
10029 /// @tparam OtherIterator The iterator type to copy from.
10030 /// @param other An iterator to copy from with different const-ness in ValueType.
10031 template <
10032 typename OtherIterator,
10033 enable_if_t<
10034 conjunction<std::is_same<OtherIterator, other_iterator_type>, std::is_const<ValueType>>::value, int> = 0>
10035 iterator(const OtherIterator& other) noexcept
10036 : m_inner_iterator_type(other.m_inner_iterator_type),
10037 m_iterator_holder(other.m_iterator_holder) {
10038 }
10039
10040 /// @brief A copy assignment operator of the iterator class.

Callers

nothing calls this directly

Calls 1

exceptionFunction · 0.85

Tested by

no test coverage detected