38 #ifndef LIBPMEMOBJ_CPP_SLICE_HPP 39 #define LIBPMEMOBJ_CPP_SLICE_HPP 43 #include <type_traits> 55 template <
typename Iterator>
58 using size_type = std::size_t;
59 using iterator = Iterator;
60 using reverse_iterator = std::reverse_iterator<iterator>;
61 using reference =
typename std::iterator_traits<iterator>::reference;
71 std::is_same<
typename std::iterator_traits<
72 iterator>::iterator_category,
73 std::random_access_iterator_tag>::value,
74 "Iterator should have RandomAccessIterator tag");
76 if (it_end < it_begin)
77 throw std::out_of_range(
"pmem::obj::slice");
114 return reverse_iterator(it_begin);
123 return reverse_iterator(it_end);
135 throw std::out_of_range(
"pmem::obj::slice");
137 return it_begin[
static_cast<typename std::iterator_traits<
138 Iterator
>::difference_type>(idx)];
147 return it_begin[
static_cast<typename std::iterator_traits<
148 Iterator
>::difference_type>(idx)];
154 return static_cast<size_type>(it_end - it_begin);
158 iterator it_begin, it_end;
reverse_iterator rend() const noexcept
Returns reverse iterator to the end.
Definition: slice.hpp:112
slice & operator=(const slice &other) noexcept=default
Defaulted assignment operator.
pmem::obj::slice - provides interface to access sequence of objects.
Definition: slice.hpp:56
iterator end() const noexcept
Returns iterator to the end of the range.
Definition: slice.hpp:103
iterator begin() const noexcept
Returns iterator to the beginning of the range.
Definition: slice.hpp:94
reference operator[](size_type idx)
Element access operator.
Definition: slice.hpp:145
reference at(size_type idx)
Element access operator.
Definition: slice.hpp:132
reverse_iterator rbegin() const noexcept
Returns reverse iterator to the beginning.
Definition: slice.hpp:121
slice(Iterator begin, Iterator end)
Constructor taking two RandomAccess iterators which define a range.
Definition: slice.hpp:68
A persistent version of concurrent hash map implementation Ref: https://arxiv.org/abs/1509....
Definition: allocation_flag.hpp:43