PMDK C++ bindings
1.10
This is the C++ bindings documentation for PMDK's libpmemobj.
|
Go to the documentation of this file.
9 #ifndef LIBPMEMOBJ_CPP_SLICE_HPP
10 #define LIBPMEMOBJ_CPP_SLICE_HPP
14 #include <type_traits>
26 template <
typename Iterator>
29 using size_type = std::size_t;
30 using iterator = Iterator;
31 using reverse_iterator = std::reverse_iterator<iterator>;
32 using reference =
typename std::iterator_traits<iterator>::reference;
42 std::is_same<
typename std::iterator_traits<
43 iterator>::iterator_category,
44 std::random_access_iterator_tag>::value,
45 "Iterator should have RandomAccessIterator tag");
47 if (it_end < it_begin)
48 throw std::out_of_range(
"pmem::obj::slice");
85 return reverse_iterator(it_begin);
94 return reverse_iterator(it_end);
106 throw std::out_of_range(
"pmem::obj::slice");
108 return it_begin[
static_cast<typename std::iterator_traits<
109 Iterator
>::difference_type>(idx)];
118 return it_begin[
static_cast<typename std::iterator_traits<
119 Iterator
>::difference_type>(idx)];
125 return static_cast<size_type
>(it_end - it_begin);
129 iterator it_begin, it_end;
Persistent memory namespace.
Definition: allocation_flag.hpp:15
reverse_iterator rbegin() const noexcept
Returns reverse iterator to the beginning.
Definition: slice.hpp:92
slice & operator=(const slice &other) noexcept=default
Defaulted assignment operator.
reference operator[](size_type idx)
Element access operator.
Definition: slice.hpp:116
slice(const slice &other) noexcept=default
Defaulted copy constructor.
pmem::obj::slice - provides interface to access sequence of objects.
Definition: slice.hpp:27
slice(Iterator begin, Iterator end)
Constructor taking two RandomAccess iterators which define a range.
Definition: slice.hpp:39
iterator begin() const noexcept
Returns iterator to the beginning of the range.
Definition: slice.hpp:65
iterator end() const noexcept
Returns iterator to the end of the range.
Definition: slice.hpp:74
reference at(size_type idx)
Element access operator.
Definition: slice.hpp:103
reverse_iterator rend() const noexcept
Returns reverse iterator to the end.
Definition: slice.hpp:83