Botan 3.4.0
Crypto and TLS for C&
Public Types | Public Member Functions | List of all members
Botan::StrongSpan< T > Class Template Reference

#include <strong_type.h>

Public Types

using const_pointer = typename underlying_span::const_pointer
 
using iterator = typename underlying_span::iterator
 
using pointer = typename underlying_span::pointer
 
using size_type = typename underlying_span::size_type
 
using value_type = typename underlying_span::value_type
 

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
 
decltype(auto) operator[] (typename underlying_span::size_type i) const noexcept
 
decltype(auto) size () const noexcept(noexcept(this->m_span.size()))
 
 StrongSpan ()=default
 
 StrongSpan (const StrongSpan &other)=default
 
template<concepts::contiguous_strong_type T2, typename = std::enable_if_t<std::is_same_v<T2, std::remove_const_t<T>>>>
 StrongSpan (const StrongSpan< T2 > &other)
 
 StrongSpan (T &strong)
 
 StrongSpan (underlying_span span)
 
 ~StrongSpan ()=default
 

Detailed Description

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

This mimmicks 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 520 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

Definition at line 529 of file strong_type.h.

◆ iterator

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

Definition at line 527 of file strong_type.h.

◆ pointer

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

Definition at line 528 of file strong_type.h.

◆ size_type

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

Definition at line 526 of file strong_type.h.

◆ value_type

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

Definition at line 525 of file strong_type.h.

Constructor & Destructor Documentation

◆ StrongSpan() [1/5]

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

◆ StrongSpan() [2/5]

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

Definition at line 533 of file strong_type.h.

533: m_span(span) {}

◆ StrongSpan() [3/5]

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

Definition at line 535 of file strong_type.h.

535: m_span(strong) {}

◆ StrongSpan() [4/5]

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

Definition at line 549 of file strong_type.h.

549: m_span(other.get()) {}

◆ StrongSpan() [5/5]

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

◆ ~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

Definition at line 575 of file strong_type.h.

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

◆ begin() [2/2]

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

Definition at line 573 of file strong_type.h.

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

Referenced by Botan::Sphincs_Hash_Functions_Sha2::PRF_msg().

◆ data() [1/2]

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

Definition at line 567 of file strong_type.h.

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

◆ data() [2/2]

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

Definition at line 565 of file strong_type.h.

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

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

◆ empty()

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

Definition at line 571 of file strong_type.h.

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

◆ end() [1/2]

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

Definition at line 579 of file strong_type.h.

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

◆ end() [2/2]

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

Definition at line 577 of file strong_type.h.

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

◆ get() [1/2]

template<concepts::contiguous_strong_type T>
underlying_span Botan::StrongSpan< T >::get ( )
inline
Returns
the underlying std::span without any type constraints

Definition at line 563 of file strong_type.h.

563{ return m_span; }

◆ get() [2/2]

template<concepts::contiguous_strong_type T>
underlying_span Botan::StrongSpan< T >::get ( ) const
inline
Returns
the underlying std::span without any type constraints

Definition at line 558 of file strong_type.h.

558{ return m_span; }

Referenced by Botan::treehash().

◆ operator[]()

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

Definition at line 581 of file strong_type.h.

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

◆ size()

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

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