Bitcoin Core  0.20.99
P2P Digital Currency
Public Member Functions | Private Attributes | Friends | List of all members
Span< C > Class Template Reference

A Span is an object that can refer to a contiguous sequence of objects. More...

#include <span.h>

Public Member Functions

constexpr Span () noexcept
 
constexpr Span (C *data, std::ptrdiff_t size) noexcept
 
constexpr Span (C *data, C *end) noexcept
 
template<typename O , typename std::enable_if< std::is_convertible< O(*)[], C(*)[]>::value, int >::type = 0>
constexpr Span (const Span< O > &other) noexcept
 Implicit conversion of spans between compatible types. More...
 
constexpr Span (const Span &) noexcept=default
 Default copy constructor. More...
 
Spanoperator= (const Span &other) noexcept=default
 Default assignment operator. More...
 
constexpr C * data () const noexcept
 
constexpr C * begin () const noexcept
 
constexpr C * end () const noexcept
 
constexpr C & front () const noexcept
 
constexpr C & back () const noexcept
 
constexpr std::ptrdiff_t size () const noexcept
 
constexpr C & operator[] (std::ptrdiff_t pos) const noexcept
 
constexpr Span< C > subspan (std::ptrdiff_t offset) const noexcept
 
constexpr Span< C > subspan (std::ptrdiff_t offset, std::ptrdiff_t count) const noexcept
 
constexpr Span< C > first (std::ptrdiff_t count) const noexcept
 
constexpr Span< C > last (std::ptrdiff_t count) const noexcept
 

Private Attributes

C * m_data
 
std::ptrdiff_t m_size
 

Friends

template<typename O >
class Span
 
constexpr bool operator== (const Span &a, const Span &b) noexcept
 
constexpr bool operator!= (const Span &a, const Span &b) noexcept
 
constexpr bool operator< (const Span &a, const Span &b) noexcept
 
constexpr bool operator<= (const Span &a, const Span &b) noexcept
 
constexpr bool operator> (const Span &a, const Span &b) noexcept
 
constexpr bool operator>= (const Span &a, const Span &b) noexcept
 

Detailed Description

template<typename C>
class Span< C >

A Span is an object that can refer to a contiguous sequence of objects.

It implements a subset of C++20's std::span.

Definition at line 18 of file span.h.

Constructor & Destructor Documentation

◆ Span() [1/5]

template<typename C>
constexpr Span< C >::Span ( )
inlinenoexcept

Definition at line 24 of file span.h.

Here is the caller graph for this function:

◆ Span() [2/5]

template<typename C>
constexpr Span< C >::Span ( C *  data,
std::ptrdiff_t  size 
)
inlinenoexcept

Definition at line 25 of file span.h.

◆ Span() [3/5]

template<typename C>
constexpr Span< C >::Span ( C *  data,
C *  end 
)
inlinenoexcept

Definition at line 26 of file span.h.

◆ Span() [4/5]

template<typename C>
template<typename O , typename std::enable_if< std::is_convertible< O(*)[], C(*)[]>::value, int >::type = 0>
constexpr Span< C >::Span ( const Span< O > &  other)
inlinenoexcept

Implicit conversion of spans between compatible types.

Specifically, if a pointer to an array of type O can be implicitly converted to a pointer to an array of type C, then permit implicit conversion of Span<O> to Span<C>. This matches the behavior of the corresponding C++20 std::span constructor.

For example this means that a Span<T> can be converted into a Span<const T>.

Definition at line 37 of file span.h.

Here is the call graph for this function:

◆ Span() [5/5]

template<typename C>
constexpr Span< C >::Span ( const Span< C > &  )
defaultnoexcept

Default copy constructor.

Member Function Documentation

◆ back()

template<typename C>
constexpr C& Span< C >::back ( ) const
inlinenoexcept

Definition at line 49 of file span.h.

Here is the caller graph for this function:

◆ begin()

template<typename C>
constexpr C* Span< C >::begin ( ) const
inlinenoexcept

Definition at line 46 of file span.h.

Here is the caller graph for this function:

◆ data()

template<typename C>
constexpr C* Span< C >::data ( ) const
inlinenoexcept

Definition at line 45 of file span.h.

Here is the caller graph for this function:

◆ end()

template<typename C>
constexpr C* Span< C >::end ( ) const
inlinenoexcept

Definition at line 47 of file span.h.

Here is the caller graph for this function:

◆ first()

template<typename C>
constexpr Span<C> Span< C >::first ( std::ptrdiff_t  count) const
inlinenoexcept

Definition at line 55 of file span.h.

Here is the caller graph for this function:

◆ front()

template<typename C>
constexpr C& Span< C >::front ( ) const
inlinenoexcept

Definition at line 48 of file span.h.

◆ last()

template<typename C>
constexpr Span<C> Span< C >::last ( std::ptrdiff_t  count) const
inlinenoexcept

Definition at line 56 of file span.h.

◆ operator=()

template<typename C>
Span& Span< C >::operator= ( const Span< C > &  other)
defaultnoexcept

Default assignment operator.

Here is the caller graph for this function:

◆ operator[]()

template<typename C>
constexpr C& Span< C >::operator[] ( std::ptrdiff_t  pos) const
inlinenoexcept

Definition at line 51 of file span.h.

◆ size()

template<typename C>
constexpr std::ptrdiff_t Span< C >::size ( ) const
inlinenoexcept

Definition at line 50 of file span.h.

Here is the caller graph for this function:

◆ subspan() [1/2]

template<typename C>
constexpr Span<C> Span< C >::subspan ( std::ptrdiff_t  offset) const
inlinenoexcept

Definition at line 53 of file span.h.

Here is the caller graph for this function:

◆ subspan() [2/2]

template<typename C>
constexpr Span<C> Span< C >::subspan ( std::ptrdiff_t  offset,
std::ptrdiff_t  count 
) const
inlinenoexcept

Definition at line 54 of file span.h.

Friends And Related Function Documentation

◆ operator!=

template<typename C>
constexpr bool operator!= ( const Span< C > &  a,
const Span< C > &  b 
)
friend

Definition at line 59 of file span.h.

◆ operator<

template<typename C>
constexpr bool operator< ( const Span< C > &  a,
const Span< C > &  b 
)
friend

Definition at line 60 of file span.h.

◆ operator<=

template<typename C>
constexpr bool operator<= ( const Span< C > &  a,
const Span< C > &  b 
)
friend

Definition at line 61 of file span.h.

◆ operator==

template<typename C>
constexpr bool operator== ( const Span< C > &  a,
const Span< C > &  b 
)
friend

Definition at line 58 of file span.h.

◆ operator>

template<typename C>
constexpr bool operator> ( const Span< C > &  a,
const Span< C > &  b 
)
friend

Definition at line 62 of file span.h.

◆ operator>=

template<typename C>
constexpr bool operator>= ( const Span< C > &  a,
const Span< C > &  b 
)
friend

Definition at line 63 of file span.h.

◆ Span

template<typename C>
template<typename O >
friend class Span
friend

Definition at line 65 of file span.h.

Member Data Documentation

◆ m_data

template<typename C>
C* Span< C >::m_data
private

Definition at line 20 of file span.h.

◆ m_size

template<typename C>
std::ptrdiff_t Span< C >::m_size
private

Definition at line 21 of file span.h.


The documentation for this class was generated from the following file: