Botan 3.13.0
Crypto and TLS for C&
Botan::StrongSpan< T > Class Template Referencefinal

#include <strong_type.h>

Public Types

using const_pointer = typename underlying_span::const_pointer
 The const pointer type of the underlying span.
using iterator = typename underlying_span::iterator
 The iterator type of the underlying span.
using pointer = typename underlying_span::pointer
 The pointer type of the underlying span.
using size_type = typename underlying_span::size_type
 The size type of the underlying span.
using value_type = typename underlying_span::value_type
 The element type of the underlying span.

Public Member Functions

decltype(auto) begin () const noexcept(noexcept(this->m_span.begin()))
decltype(auto) begin () noexcept(noexcept(this->m_span.begin()))
decltype(auto) data () const noexcept(noexcept(this->m_span.data()))
decltype(auto) data () noexcept(noexcept(this->m_span.data()))
bool empty () const noexcept(noexcept(this->m_span.empty()))
decltype(auto) end () const noexcept(noexcept(this->m_span.end()))
decltype(auto) end () noexcept(noexcept(this->m_span.end()))
underlying_span get ()
underlying_span get () const
StrongSpanoperator= (const StrongSpan &other)=default
StrongSpanoperator= (StrongSpan &&other)=default
decltype(auto) operator[] (typename underlying_span::size_type i) const noexcept
decltype(auto) size () const noexcept(noexcept(this->m_span.size()))
 StrongSpan ()=default
 Default constructor, creates an empty span.
 StrongSpan (const StrongSpan &other)=default
template<concepts::contiguous_strong_type T2>
requires (std::is_same_v<T2, std::remove_const_t<T>>)
 StrongSpan (const StrongSpan< T2 > &other)
 StrongSpan (StrongSpan &&other)=default
 StrongSpan (T &strong)
 StrongSpan (underlying_span span)
 ~StrongSpan ()=default

Detailed Description

template<concepts::contiguous_strong_type T>
class Botan::StrongSpan< T >

This mimics a std::span but keeps track of the strong-type information. Use this when you would want to use const Strong<...>& as a parameter declaration. In particular this allows assigning strong-type information to slices of a bigger buffer without copying the bytes. E.g:

using Foo = Strong<std::vector<uint8_t>, Foo_>;

void bar(StrongSpan<Foo> foo) { ... }

std::vector<uint8_t> buffer; BufferSlicer slicer(buffer); bar(slicer.take<Foo>()); // This does not copy the data from buffer but // just annotates the 'Foo' strong-type info.

Definition at line 1083 of file strong_type.h.

Member Typedef Documentation

◆ const_pointer

template<concepts::contiguous_strong_type T>
using Botan::StrongSpan< T >::const_pointer = typename underlying_span::const_pointer

The const pointer type of the underlying span.

Definition at line 1101 of file strong_type.h.

◆ iterator

template<concepts::contiguous_strong_type T>
using Botan::StrongSpan< T >::iterator = typename underlying_span::iterator

The iterator type of the underlying span.

Definition at line 1095 of file strong_type.h.

◆ pointer

template<concepts::contiguous_strong_type T>
using Botan::StrongSpan< T >::pointer = typename underlying_span::pointer

The pointer type of the underlying span.

Definition at line 1098 of file strong_type.h.

◆ size_type

template<concepts::contiguous_strong_type T>
using Botan::StrongSpan< T >::size_type = typename underlying_span::size_type

The size type of the underlying span.

Definition at line 1092 of file strong_type.h.

◆ value_type

template<concepts::contiguous_strong_type T>
using Botan::StrongSpan< T >::value_type = typename underlying_span::value_type

The element type of the underlying span.

Definition at line 1089 of file strong_type.h.

Constructor & Destructor Documentation

◆ StrongSpan() [1/6]

template<concepts::contiguous_strong_type T>
Botan::StrongSpan< T >::StrongSpan ( )
default

Default constructor, creates an empty span.

Referenced by operator=(), operator=(), StrongSpan(), StrongSpan(), and StrongSpan().

◆ StrongSpan() [2/6]

template<concepts::contiguous_strong_type T>
Botan::StrongSpan< T >::StrongSpan ( underlying_span span)
inlineexplicit

Annotate a plain span with this strong type's information

Parameters
spanthe span to annotate

Definition at line 1108 of file strong_type.h.

1108: m_span(span) {}

◆ StrongSpan() [3/6]

template<concepts::contiguous_strong_type T>
Botan::StrongSpan< T >::StrongSpan ( T & strong)
inline

Create a span covering the contents of a strong type

Parameters
strongthe strong type to view

Definition at line 1113 of file strong_type.h.

1113: m_span(strong) {}

◆ StrongSpan() [4/6]

template<concepts::contiguous_strong_type T>
template<concepts::contiguous_strong_type T2>
requires (std::is_same_v<T2, std::remove_const_t<T>>)
Botan::StrongSpan< T >::StrongSpan ( const StrongSpan< T2 > & other)
inline

Convert a StrongSpan<T> to a StrongSpan<const T>

Parameters
otherthe span to convert

Definition at line 1129 of file strong_type.h.

1131 : m_span(other.get()) {}
underlying_span get() const

References get(), and StrongSpan().

◆ StrongSpan() [5/6]

template<concepts::contiguous_strong_type T>
Botan::StrongSpan< T >::StrongSpan ( const StrongSpan< T > & other)
default

Copy constructor

Parameters
otherthe span to copy

References StrongSpan().

◆ StrongSpan() [6/6]

template<concepts::contiguous_strong_type T>
Botan::StrongSpan< T >::StrongSpan ( StrongSpan< T > && other)
default

Move constructor

Parameters
otherthe span to move from

References StrongSpan().

◆ ~StrongSpan()

template<concepts::contiguous_strong_type T>
Botan::StrongSpan< T >::~StrongSpan ( )
default

Member Function Documentation

◆ begin() [1/2]

template<concepts::contiguous_strong_type T>
decltype(auto) Botan::StrongSpan< T >::begin ( ) const
inlinenoexcept

Iterate the span

Returns
a const iterator to the first element

Definition at line 1187 of file strong_type.h.

1187{ return this->m_span.begin(); }

References begin().

◆ begin() [2/2]

template<concepts::contiguous_strong_type T>
decltype(auto) Botan::StrongSpan< T >::begin ( )
inlinenoexcept

Iterate the span

Returns
an iterator to the first element

Definition at line 1183 of file strong_type.h.

1183{ return this->m_span.begin(); }

References begin().

Referenced by begin(), begin(), Botan::Classic_McEliece_KeyPair_Internal::generate(), and Botan::Sphincs_Hash_Functions_Sha2::PRF_msg().

◆ data() [1/2]

template<concepts::contiguous_strong_type T>
decltype(auto) Botan::StrongSpan< T >::data ( ) const
inlinenoexcept

Access the underlying storage

Returns
a const pointer to the first element

Definition at line 1171 of file strong_type.h.

1171{ return this->m_span.data(); }

◆ data() [2/2]

template<concepts::contiguous_strong_type T>
decltype(auto) Botan::StrongSpan< T >::data ( )
inlinenoexcept

Access the underlying storage

Returns
a pointer to the first element

Definition at line 1167 of file strong_type.h.

1167{ return this->m_span.data(); }

Referenced by Botan::ML_KEM_Decryptor::decapsulate(), Botan::FrodoMatrix::deserialize(), and Botan::FrodoMatrix::sample().

◆ empty()

template<concepts::contiguous_strong_type T>
bool Botan::StrongSpan< T >::empty ( ) const
inlinenoexcept

Query whether the span is empty

Returns
true if the span covers no elements

Definition at line 1179 of file strong_type.h.

1179{ return this->m_span.empty(); }

References empty().

Referenced by empty().

◆ end() [1/2]

template<concepts::contiguous_strong_type T>
decltype(auto) Botan::StrongSpan< T >::end ( ) const
inlinenoexcept

Iterate the span

Returns
a const iterator one past the last element

Definition at line 1195 of file strong_type.h.

1195{ return this->m_span.end(); }

References end().

◆ end() [2/2]

template<concepts::contiguous_strong_type T>
decltype(auto) Botan::StrongSpan< T >::end ( )
inlinenoexcept

Iterate the span

Returns
an iterator one past the last element

Definition at line 1191 of file strong_type.h.

1191{ return this->m_span.end(); }

References end().

Referenced by end(), end(), and Botan::Classic_McEliece_KeyPair_Internal::generate().

◆ get() [1/2]

template<concepts::contiguous_strong_type T>
underlying_span Botan::StrongSpan< T >::get ( )
inline

Access the underlying span

Returns
the underlying std::span without any type constraints

Definition at line 1163 of file strong_type.h.

1163{ return m_span; }

◆ get() [2/2]

template<concepts::contiguous_strong_type T>
underlying_span Botan::StrongSpan< T >::get ( ) const
inline

Access the underlying span

Returns
the underlying std::span without any type constraints

Definition at line 1157 of file strong_type.h.

1157{ return m_span; }

Referenced by StrongSpan(), and Botan::treehash().

◆ operator=() [1/2]

template<concepts::contiguous_strong_type T>
StrongSpan & Botan::StrongSpan< T >::operator= ( const StrongSpan< T > & other)
default

Copy assignment

Parameters
otherthe span to copy
Returns
reference to this

References StrongSpan().

◆ operator=() [2/2]

template<concepts::contiguous_strong_type T>
StrongSpan & Botan::StrongSpan< T >::operator= ( StrongSpan< T > && other)
default

Move assignment

Parameters
otherthe span to move from
Returns
reference to this

References StrongSpan().

◆ operator[]()

template<concepts::contiguous_strong_type T>
decltype(auto) Botan::StrongSpan< T >::operator[] ( typename underlying_span::size_type i) const
inlinenoexcept

Element access

Parameters
ithe index of the element
Returns
reference to the element at index i

Definition at line 1200 of file strong_type.h.

1200{ return this->m_span[i]; }

◆ size()


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