6#ifndef ALT_INTEGRATION_VERIBLOCK_SLICE_HPP
7#define ALT_INTEGRATION_VERIBLOCK_SLICE_HPP
21template <
class ElementType>
23 using element_type = ElementType;
24 using value_type =
typename std::remove_cv<ElementType>::type;
25 using index_type = std::ptrdiff_t;
26 using pointer = element_type *;
27 using reference = element_type &;
29 using iterator = pointer;
30 using const_iterator =
const pointer;
31 using reverse_iterator = std::reverse_iterator<iterator>;
32 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
34 Slice() : storage_(
nullptr), size_(0) {}
36 Slice(
const pointer ptr,
size_t size) : storage_(ptr), size_(size) {}
42 typename =
typename std::enable_if<
43 sizeof(
typename Container::value_type) == 1 ||
44 std::is_same<
typename std::remove_const<ElementType>::type,
45 typename std::remove_const<
46 typename Container::value_type>::type>::value>::type>
47 constexpr Slice(Container &cont) noexcept
48 :
Slice(
reinterpret_cast<const pointer
>(cont.data()), cont.size()) {}
50 constexpr pointer data()
const noexcept {
return storage_; }
52 constexpr size_t size()
const noexcept {
return size_; }
54 constexpr reference operator[](index_type idx)
const {
return data()[idx]; }
56 constexpr std::vector<value_type> asVector()
const {
57 return std::vector<value_type>{storage_, storage_ + size_};
60 constexpr iterator begin()
const noexcept {
return storage_; }
61 constexpr iterator end()
const noexcept {
return storage_ + size_; }
62 constexpr iterator cbegin()
const noexcept {
return storage_; }
63 constexpr iterator cend()
const noexcept {
return storage_ + size_; }
64 constexpr reverse_iterator rbegin()
const noexcept {
65 return reverse_iterator{end()};
67 constexpr reverse_iterator rend()
const noexcept {
68 return reverse_iterator{begin()};
70 constexpr const_reverse_iterator crbegin()
const noexcept {
71 return const_reverse_iterator{cend()};
73 constexpr const_reverse_iterator crend()
const noexcept {
74 return const_reverse_iterator{cbegin()};
77 std::vector<value_type> reverse()
const {
78 return std::vector<value_type>(rbegin(), rend());
90 *os <<
"Slice(" << slice.data() <<
", " << slice.size() <<
")";
void PrintTo(const ArithUint256 &uint, ::std::ostream *os)
custom gtest printer, which prints Blob of any size as hexstring @ private
Non-owning contiguous array.