Bitcoin Core  27.99.0
P2P Digital Currency
Classes | Macros | Typedefs | Functions | Variables
span.h File Reference
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <span>
#include <type_traits>
Include dependency graph for span.h:

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
 

Typedefs

template<typename T >
using DataResult = std::remove_pointer_t< decltype(std::declval< T & >().data())>
 

Functions

template<typename T , typename EndOrSize >
 Span (T *, EndOrSize) -> Span< T >
 
template<typename T , std::size_t N>
 Span (T(&)[N]) -> Span< T >
 
template<typename T >
 Span (T &&) -> Span< std::enable_if_t<!std::is_lvalue_reference_v< T > &&!std::is_void_v< DataResult< T && >>, const DataResult< T && >>>
 
template<typename T >
 Span (T &) -> Span< std::enable_if_t<!std::is_void_v< DataResult< T & >>, DataResult< T & >>>
 
template<typename T >
T & SpanPopBack (Span< T > &span)
 Pop the last element off a span, and return a reference to that element. More...
 
template<typename T >
Span< const std::byte > AsBytes (Span< T > s) noexcept
 
template<typename T >
Span< std::byte > AsWritableBytes (Span< T > s) noexcept
 
template<typename V >
Span< const std::byte > MakeByteSpan (V &&v) noexcept
 
template<typename V >
Span< std::byte > MakeWritableByteSpan (V &&v) noexcept
 
unsigned char * UCharCast (char *c)
 
unsigned char * UCharCast (unsigned char *c)
 
unsigned char * UCharCast (signed char *c)
 
unsigned char * UCharCast (std::byte *c)
 
const unsigned char * UCharCast (const char *c)
 
const unsigned char * UCharCast (const unsigned char *c)
 
const unsigned char * UCharCast (const signed char *c)
 
const unsigned char * UCharCast (const std::byte *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(Span{std::forward< V >(v)}))
 Like the Span constructor, but for (const) unsigned char member types only. More...
 

Variables

template<typename B >
concept BasicByte = requires { UCharCast(std::span<B>{}.data()); }
 

Macro Definition Documentation

◆ ASSERT_IF_DEBUG

#define ASSERT_IF_DEBUG (   x)

Definition at line 19 of file span.h.

◆ CONSTEXPR_IF_NOT_DEBUG

#define CONSTEXPR_IF_NOT_DEBUG   constexpr

Definition at line 18 of file span.h.

◆ SPAN_ATTR_LIFETIMEBOUND

#define SPAN_ATTR_LIFETIMEBOUND

Definition at line 29 of file span.h.

Typedef Documentation

◆ DataResult

template<typename T >
using DataResult = std::remove_pointer_t<decltype(std::declval<T&>().data())>

Definition at line 241 of file span.h.

Function Documentation

◆ AsBytes()

template<typename T >
Span<const std::byte> AsBytes ( Span< T >  s)
noexcept

Definition at line 266 of file span.h.

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

◆ AsWritableBytes()

template<typename T >
Span<std::byte> AsWritableBytes ( Span< T >  s)
noexcept

Definition at line 271 of file span.h.

Here is the caller graph for this function:

◆ MakeByteSpan()

template<typename V >
Span<const std::byte> MakeByteSpan ( V &&  v)
noexcept

Definition at line 277 of file span.h.

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

◆ MakeUCharSpan()

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

Like the Span constructor, but for (const) unsigned char member types only.

Only works for (un)signed char containers.

Definition at line 304 of file span.h.

Here is the caller graph for this function:

◆ MakeWritableByteSpan()

template<typename V >
Span<std::byte> MakeWritableByteSpan ( V &&  v)
noexcept

Definition at line 282 of file span.h.

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

◆ Span() [1/4]

template<typename T >
Span ( T &&  ) -> Span< std::enable_if_t<!std::is_lvalue_reference_v< T > &&!std::is_void_v< DataResult< T && >>, const DataResult< T && >>>

◆ Span() [2/4]

template<typename T >
Span ( T &  ) -> Span< std::enable_if_t<!std::is_void_v< DataResult< T & >>, DataResult< T & >>>

◆ Span() [3/4]

template<typename T , typename EndOrSize >
Span ( T *  ,
EndOrSize   
) -> Span< T >
Here is the caller graph for this function:

◆ Span() [4/4]

template<typename T , std::size_t N>
Span ( T(&)  [N]) -> Span< T >

◆ 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 255 of file span.h.

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

◆ UCharCast() [1/8]

unsigned char* UCharCast ( char *  c)
inline

Definition at line 288 of file span.h.

Here is the caller graph for this function:

◆ UCharCast() [2/8]

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

Definition at line 292 of file span.h.

◆ UCharCast() [3/8]

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

Definition at line 294 of file span.h.

◆ UCharCast() [4/8]

const unsigned char* UCharCast ( const std::byte *  c)
inline

Definition at line 295 of file span.h.

◆ UCharCast() [5/8]

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

Definition at line 293 of file span.h.

◆ UCharCast() [6/8]

unsigned char* UCharCast ( signed char *  c)
inline

Definition at line 290 of file span.h.

◆ UCharCast() [7/8]

unsigned char* UCharCast ( std::byte *  c)
inline

Definition at line 291 of file span.h.

◆ UCharCast() [8/8]

unsigned char* UCharCast ( unsigned char *  c)
inline

Definition at line 289 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 301 of file span.h.

Here is the call graph for this function:

Variable Documentation

◆ BasicByte

template<typename B >
concept BasicByte = requires { UCharCast(std::span<B>{}.data()); }

Definition at line 298 of file span.h.