PMDK C++ bindings
1.5.2
This is the C++ bindings documentation for PMDK's libpmemobj.
|
Go to the documentation of this file.
38 #ifndef LIBPMEMOBJ_CPP_SLICE_HPP
39 #define LIBPMEMOBJ_CPP_SLICE_HPP
42 #include <type_traits>
50 namespace experimental
57 template <
typename Iterator>
60 using size_type = std::size_t;
61 using iterator = Iterator;
62 using reverse_iterator = std::reverse_iterator<iterator>;
63 using reference =
typename std::iterator_traits<iterator>::reference;
73 std::is_same<
typename std::iterator_traits<
74 iterator>::iterator_category,
75 std::random_access_iterator_tag>::value,
76 "Iterator should have RandomAccessIterator tag");
78 if (it_end < it_begin)
79 throw std::out_of_range(
"pmem::obj::slice");
116 return reverse_iterator(it_begin);
125 return reverse_iterator(it_end);
137 throw std::out_of_range(
"pmem::obj::slice");
139 return it_begin[
static_cast<typename std::iterator_traits<
140 Iterator
>::difference_type>(idx)];
149 return it_begin[
static_cast<typename std::iterator_traits<
150 Iterator
>::difference_type>(idx)];
156 return static_cast<size_type
>(it_end - it_begin);
160 iterator it_begin, it_end;
slice & operator=(const slice &other) noexcept=default
Defaulted assignment operator.
reference operator[](size_type idx)
Element access operator.
Definition: slice.hpp:147
pmem::obj::experimental::slice - provides interface to access sequence of objects.
Definition: slice.hpp:58
reverse_iterator rbegin() const noexcept
Returns reverse iterator to the beginning.
Definition: slice.hpp:123
slice(Iterator begin, Iterator end)
Constructor taking two RandomAccess iterators which define a range.
Definition: slice.hpp:70
reference at(size_type idx)
Element access operator.
Definition: slice.hpp:134
slice(const slice &other) noexcept=default
Defaulted copy constructor.
iterator end() const noexcept
Returns iterator to the end of the range.
Definition: slice.hpp:105
iterator begin() const noexcept
Returns iterator to the beginning of the range.
Definition: slice.hpp:96
reverse_iterator rend() const noexcept
Returns reverse iterator to the end.
Definition: slice.hpp:114