veriblock-pop-cpp
C++11 Libraries for leveraging VeriBlock Proof-Of-Proof blockchain technology.
altintegration::Slice< ElementType > Struct Template Reference

Non-owning contiguous array. More...

Detailed Description

template<class ElementType>
struct altintegration::Slice< ElementType >

Similar to gsl::span. Essentially, just a pair T* + size_t

Definition at line 22 of file slice.hpp.

+ Collaboration diagram for altintegration::Slice< ElementType >:

Public Types

using element_type = ElementType
 
using value_type = typename std::remove_cv< ElementType >::type
 
using index_type = std::ptrdiff_t
 
using pointer = element_type *
 
using reference = element_type &
 
using iterator = pointer
 
using const_iterator = const pointer
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 

Public Member Functions

 Slice (const pointer ptr, size_t size)
 
template<class Container , typename = typename std::enable_if< sizeof(typename Container::value_type) == 1 || std::is_same<typename std::remove_const<ElementType>::type, typename std::remove_const< typename Container::value_type>::type>::value>::type>
constexpr Slice (Container &cont) noexcept
 
constexpr pointer data () const noexcept
 
constexpr size_t size () const noexcept
 
constexpr reference operator[] (index_type idx) const
 
constexpr std::vector< value_type > asVector () const
 
constexpr iterator begin () const noexcept
 
constexpr iterator end () const noexcept
 
constexpr iterator cbegin () const noexcept
 
constexpr iterator cend () const noexcept
 
constexpr reverse_iterator rbegin () const noexcept
 
constexpr reverse_iterator rend () const noexcept
 
constexpr const_reverse_iterator crbegin () const noexcept
 
constexpr const_reverse_iterator crend () const noexcept
 
std::vector< value_type > reverse () const
 

Member Typedef Documentation

◆ const_iterator

template<class ElementType >
using altintegration::Slice< ElementType >::const_iterator = const pointer

Definition at line 30 of file slice.hpp.

◆ const_reverse_iterator

template<class ElementType >
using altintegration::Slice< ElementType >::const_reverse_iterator = std::reverse_iterator<const_iterator>

Definition at line 32 of file slice.hpp.

◆ element_type

template<class ElementType >
using altintegration::Slice< ElementType >::element_type = ElementType

Definition at line 23 of file slice.hpp.

◆ index_type

template<class ElementType >
using altintegration::Slice< ElementType >::index_type = std::ptrdiff_t

Definition at line 25 of file slice.hpp.

◆ iterator

template<class ElementType >
using altintegration::Slice< ElementType >::iterator = pointer

Definition at line 29 of file slice.hpp.

◆ pointer

template<class ElementType >
using altintegration::Slice< ElementType >::pointer = element_type *

Definition at line 26 of file slice.hpp.

◆ reference

template<class ElementType >
using altintegration::Slice< ElementType >::reference = element_type &

Definition at line 27 of file slice.hpp.

◆ reverse_iterator

template<class ElementType >
using altintegration::Slice< ElementType >::reverse_iterator = std::reverse_iterator<iterator>

Definition at line 31 of file slice.hpp.

◆ value_type

template<class ElementType >
using altintegration::Slice< ElementType >::value_type = typename std::remove_cv<ElementType>::type

Definition at line 24 of file slice.hpp.

Constructor & Destructor Documentation

◆ Slice() [1/3]

template<class ElementType >
altintegration::Slice< ElementType >::Slice ( )
inline

Definition at line 34 of file slice.hpp.

34: storage_(nullptr), size_(0) {}

◆ Slice() [2/3]

template<class ElementType >
altintegration::Slice< ElementType >::Slice ( const pointer  ptr,
size_t  size 
)
inline

Definition at line 36 of file slice.hpp.

36: storage_(ptr), size_(size) {}

◆ Slice() [3/3]

template<class ElementType >
template<class Container , typename = typename std::enable_if< sizeof(typename Container::value_type) == 1 || std::is_same<typename std::remove_const<ElementType>::type, typename std::remove_const< typename Container::value_type>::type>::value>::type>
constexpr altintegration::Slice< ElementType >::Slice ( Container &  cont)
inlineconstexprnoexcept

Definition at line 47 of file slice.hpp.

48 : Slice(reinterpret_cast<const pointer>(cont.data()), cont.size()) {}

Member Function Documentation

◆ asVector()

template<class ElementType >
constexpr std::vector< value_type > altintegration::Slice< ElementType >::asVector ( ) const
inlineconstexpr

Definition at line 56 of file slice.hpp.

56 {
57 return std::vector<value_type>{storage_, storage_ + size_};
58 }

◆ begin()

template<class ElementType >
constexpr iterator altintegration::Slice< ElementType >::begin ( ) const
inlineconstexprnoexcept

Definition at line 60 of file slice.hpp.

60{ return storage_; }

◆ cbegin()

template<class ElementType >
constexpr iterator altintegration::Slice< ElementType >::cbegin ( ) const
inlineconstexprnoexcept

Definition at line 62 of file slice.hpp.

62{ return storage_; }

◆ cend()

template<class ElementType >
constexpr iterator altintegration::Slice< ElementType >::cend ( ) const
inlineconstexprnoexcept

Definition at line 63 of file slice.hpp.

63{ return storage_ + size_; }

◆ crbegin()

template<class ElementType >
constexpr const_reverse_iterator altintegration::Slice< ElementType >::crbegin ( ) const
inlineconstexprnoexcept

Definition at line 70 of file slice.hpp.

70 {
71 return const_reverse_iterator{cend()};
72 }

◆ crend()

template<class ElementType >
constexpr const_reverse_iterator altintegration::Slice< ElementType >::crend ( ) const
inlineconstexprnoexcept

Definition at line 73 of file slice.hpp.

73 {
74 return const_reverse_iterator{cbegin()};
75 }

◆ data()

template<class ElementType >
constexpr pointer altintegration::Slice< ElementType >::data ( ) const
inlineconstexprnoexcept

Definition at line 50 of file slice.hpp.

50{ return storage_; }

◆ end()

template<class ElementType >
constexpr iterator altintegration::Slice< ElementType >::end ( ) const
inlineconstexprnoexcept

Definition at line 61 of file slice.hpp.

61{ return storage_ + size_; }

◆ operator[]()

template<class ElementType >
constexpr reference altintegration::Slice< ElementType >::operator[] ( index_type  idx) const
inlineconstexpr

Definition at line 54 of file slice.hpp.

54{ return data()[idx]; }

◆ rbegin()

template<class ElementType >
constexpr reverse_iterator altintegration::Slice< ElementType >::rbegin ( ) const
inlineconstexprnoexcept

Definition at line 64 of file slice.hpp.

64 {
65 return reverse_iterator{end()};
66 }

◆ rend()

template<class ElementType >
constexpr reverse_iterator altintegration::Slice< ElementType >::rend ( ) const
inlineconstexprnoexcept

Definition at line 67 of file slice.hpp.

67 {
68 return reverse_iterator{begin()};
69 }

◆ reverse()

template<class ElementType >
std::vector< value_type > altintegration::Slice< ElementType >::reverse ( ) const
inline

Definition at line 77 of file slice.hpp.

77 {
78 return std::vector<value_type>(rbegin(), rend());
79 }

◆ size()

template<class ElementType >
constexpr size_t altintegration::Slice< ElementType >::size ( ) const
inlineconstexprnoexcept

Definition at line 52 of file slice.hpp.

52{ return size_; }

The documentation for this struct was generated from the following files: