Bitcoin Core  22.99.0
P2P Digital Currency
Classes | Macros | Functions
span.h File Reference
#include <type_traits>
#include <cstddef>
#include <algorithm>
#include <assert.h>
Include dependency graph for span.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Span< C >
 A Span is an object that can refer to a contiguous sequence of objects. More...
 
struct  Span< C >::is_Span_int< T >
 
struct  Span< C >::is_Span_int< Span< T > >
 
struct  Span< C >::is_Span< T >
 

Macros

#define CONSTEXPR_IF_NOT_DEBUG   constexpr
 
#define ASSERT_IF_DEBUG(x)
 
#define SPAN_ATTR_LIFETIMEBOUND
 

Functions

template<typename A , int N>
constexpr Span< A > MakeSpan (A(&a)[N])
 MakeSpan for arrays: More...
 
template<typename V >
constexpr auto MakeSpan (V &&v SPAN_ATTR_LIFETIMEBOUND) -> typename std::enable_if<!std::is_lvalue_reference< V >::value, Span< const typename std::remove_pointer< decltype(v.data())>::type >>::type
 MakeSpan for temporaries / rvalue references, only supporting const output. More...
 
template<typename V >
constexpr auto MakeSpan (V &v SPAN_ATTR_LIFETIMEBOUND) -> Span< typename std::remove_pointer< decltype(v.data())>::type >
 MakeSpan for (lvalue) references, supporting mutable output. More...
 
template<typename T >
TSpanPopBack (Span< T > &span)
 Pop the last element off a span, and return a reference to that element. More...
 
unsigned char * UCharCast (char *c)
 
unsigned char * UCharCast (unsigned char *c)
 
const unsigned char * UCharCast (const char *c)
 
const unsigned char * UCharCast (const unsigned char *c)
 
template<typename T >
constexpr auto UCharSpanCast (Span< T > s) -> Span< typename std::remove_pointer< decltype(UCharCast(s.data()))>::type >
 
template<typename V >
constexpr auto MakeUCharSpan (V &&v) -> decltype(UCharSpanCast(MakeSpan(std::forward< V >(v))))
 Like MakeSpan, but for (const) unsigned char member types only. More...
 

Macro Definition Documentation

◆ ASSERT_IF_DEBUG

#define ASSERT_IF_DEBUG (   x)

Definition at line 18 of file span.h.

◆ CONSTEXPR_IF_NOT_DEBUG

#define CONSTEXPR_IF_NOT_DEBUG   constexpr

Definition at line 17 of file span.h.

◆ SPAN_ATTR_LIFETIMEBOUND

#define SPAN_ATTR_LIFETIMEBOUND

Definition at line 28 of file span.h.

Function Documentation

◆ MakeSpan() [1/3]

template<typename A , int N>
constexpr Span<A> MakeSpan ( A(&)  a[N])
constexpr

MakeSpan for arrays:

Definition at line 222 of file span.h.

Here is the caller graph for this function:

◆ MakeSpan() [2/3]

template<typename V >
constexpr auto MakeSpan ( V &&v  SPAN_ATTR_LIFETIMEBOUND) -> typename std::enable_if<!std::is_lvalue_reference<V>::value, Span<const typename std::remove_pointer<decltype(v.data())>::type>>::type
constexpr

MakeSpan for temporaries / rvalue references, only supporting const output.

Definition at line 224 of file span.h.

◆ MakeSpan() [3/3]

template<typename V >
constexpr auto MakeSpan ( V &v  SPAN_ATTR_LIFETIMEBOUND) -> Span<typename std::remove_pointer<decltype(v.data())>::type>
constexpr

MakeSpan for (lvalue) references, supporting mutable output.

Definition at line 226 of file span.h.

◆ MakeUCharSpan()

template<typename V >
constexpr auto MakeUCharSpan ( V &&  v) -> decltype(UCharSpanCast(MakeSpan(std::forward<V>(v))))
constexpr

Like MakeSpan, but for (const) unsigned char member types only.

Only works for (un)signed char containers.

Definition at line 249 of file span.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SpanPopBack()

template<typename T >
T& SpanPopBack ( Span< T > &  span)

Pop the last element off a span, and return a reference to that element.

Definition at line 230 of file span.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UCharCast() [1/4]

unsigned char* UCharCast ( char *  c)
inline

Definition at line 240 of file span.h.

Here is the caller graph for this function:

◆ UCharCast() [2/4]

const unsigned char* UCharCast ( const char *  c)
inline

Definition at line 242 of file span.h.

◆ UCharCast() [3/4]

const unsigned char* UCharCast ( const unsigned char *  c)
inline

Definition at line 243 of file span.h.

◆ UCharCast() [4/4]

unsigned char* UCharCast ( unsigned char *  c)
inline

Definition at line 241 of file span.h.

◆ UCharSpanCast()

template<typename T >
constexpr auto UCharSpanCast ( Span< T s) -> Span<typename std::remove_pointer<decltype(UCharCast(s.data()))>::type>
constexpr

Definition at line 246 of file span.h.

Here is the call graph for this function:
Here is the caller graph for this function: