PMDK C++ bindings
1.6.1
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
43 #include <type_traits>
51 namespace experimental
58 template <
typename Iterator>
61 using size_type = std::size_t;
62 using iterator = Iterator;
63 using reverse_iterator = std::reverse_iterator<iterator>;
64 using reference =
typename std::iterator_traits<iterator>::reference;
74 std::is_same<
typename std::iterator_traits<
75 iterator>::iterator_category,
76 std::random_access_iterator_tag>::value,
77 "Iterator should have RandomAccessIterator tag");
79 if (it_end < it_begin)
80 throw std::out_of_range(
"pmem::obj::slice");
117 return reverse_iterator(it_begin);
126 return reverse_iterator(it_end);
138 throw std::out_of_range(
"pmem::obj::slice");
140 return it_begin[
static_cast<typename std::iterator_traits<
141 Iterator
>::difference_type>(idx)];
150 return it_begin[
static_cast<typename std::iterator_traits<
151 Iterator
>::difference_type>(idx)];
157 return static_cast<size_type
>(it_end - it_begin);
161 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:148
pmem::obj::experimental::slice - provides interface to access sequence of objects.
Definition: slice.hpp:59
reverse_iterator rbegin() const noexcept
Returns reverse iterator to the beginning.
Definition: slice.hpp:124
slice(Iterator begin, Iterator end)
Constructor taking two RandomAccess iterators which define a range.
Definition: slice.hpp:71
reference at(size_type idx)
Element access operator.
Definition: slice.hpp:135
slice(const slice &other) noexcept=default
Defaulted copy constructor.
iterator end() const noexcept
Returns iterator to the end of the range.
Definition: slice.hpp:106
iterator begin() const noexcept
Returns iterator to the beginning of the range.
Definition: slice.hpp:97
reverse_iterator rend() const noexcept
Returns reverse iterator to the end.
Definition: slice.hpp:115