1 #ifndef PROTOZERO_ITERATORS_HPP 2 #define PROTOZERO_ITERATORS_HPP 26 #if PROTOZERO_BYTE_ORDER != PROTOZERO_LITTLE_ENDIAN 37 template <
typename T,
typename P = std::pair<T, T>>
39 #ifdef PROTOZERO_STRICT_API 52 using value_type =
typename std::iterator_traits<T>::value_type;
68 P(std::forward<
iterator>(first_iterator),
69 std::forward<
iterator>(last_iterator)) {
93 constexpr std::size_t
empty() const noexcept {
103 protozero_assert(!
empty());
104 return *(this->first);
113 protozero_assert(!
empty());
124 swap(this->first, other.first);
125 swap(this->second, other.second);
136 template <
typename T>
145 template <
typename T>
156 using iterator_category = std::forward_iterator_tag;
157 using value_type = T;
158 using difference_type = std::ptrdiff_t;
159 using pointer = value_type*;
160 using reference = value_type&;
180 value_type operator*()
const {
182 std::memcpy(&result, m_data,
sizeof(value_type));
183 #if PROTOZERO_BYTE_ORDER != PROTOZERO_LITTLE_ENDIAN 184 detail::byteswap_inplace(&result);
201 return m_data == rhs.m_data && m_end == rhs.m_end;
205 return !(*
this == rhs);
214 template <
typename T>
227 using iterator_category = std::forward_iterator_tag;
228 using value_type = T;
229 using difference_type = std::ptrdiff_t;
230 using pointer = value_type*;
231 using reference = value_type&;
251 value_type operator*()
const {
252 const char* d = m_data;
272 return !(*
this == rhs);
281 template <
typename T>
286 using iterator_category = std::forward_iterator_tag;
287 using value_type = T;
288 using difference_type = std::ptrdiff_t;
289 using pointer = value_type*;
290 using reference = value_type&;
308 value_type operator*()
const {
309 const char* d = this->m_data;
328 #endif // PROTOZERO_ITERATORS_HPP constexpr iterator cbegin() const noexcept
Return iterator to beginning of range.
Definition: iterators.hpp:83
typename std::iterator_traits< T >::value_type value_type
The value type of the underlying iterator.
Definition: iterators.hpp:52
constexpr int64_t decode_zigzag64(uint64_t value) noexcept
Definition: varint.hpp:181
Definition: iterators.hpp:146
void swap(iterator_range &other) noexcept
Definition: iterators.hpp:122
constexpr iterator begin() const noexcept
Return iterator to beginning of range.
Definition: iterators.hpp:73
T iterator
The type of the iterators in this range.
Definition: iterators.hpp:49
constexpr iterator end() const noexcept
Return iterator to end of range.
Definition: iterators.hpp:78
Contains macro checks for different configurations.
constexpr std::size_t empty() const noexcept
Return true if this range is empty.
Definition: iterators.hpp:93
constexpr iterator_range(iterator &&first_iterator, iterator &&last_iterator)
Definition: iterators.hpp:67
void swap(iterator_range< T > &lhs, iterator_range< T > &rhs) noexcept
Definition: iterators.hpp:137
void skip_varint(const char **data, const char *end)
Definition: varint.hpp:112
void drop_front()
Definition: iterators.hpp:112
const char * m_end
Pointer to end iterator position.
Definition: iterators.hpp:223
const char * m_data
Pointer to current iterator position.
Definition: iterators.hpp:220
Contains functions to swap bytes in values (for different endianness).
constexpr iterator_range()
Definition: iterators.hpp:57
Definition: iterators.hpp:282
bool operator==(const data_view &lhs, const data_view &rhs) noexcept
Definition: types.hpp:186
Definition: iterators.hpp:215
bool operator!=(const data_view &lhs, const data_view &rhs) noexcept
Definition: types.hpp:197
Definition: iterators.hpp:38
Contains low-level varint and zigzag encoding and decoding functions.
value_type front() const
Definition: iterators.hpp:102
uint64_t decode_varint(const char **data, const char *end)
Definition: varint.hpp:89
constexpr iterator cend() const noexcept
Return iterator to end of range.
Definition: iterators.hpp:88
All parts of the protozero header-only library are in this namespace.
Definition: byteswap.hpp:24