Botan 3.6.1
Crypto and TLS for C&
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 614 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 623 of file strong_type.h.

◆ iterator

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

Definition at line 621 of file strong_type.h.

◆ pointer

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

Definition at line 622 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 620 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 619 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 627 of file strong_type.h.

627: m_span(span) {}

◆ StrongSpan() [3/5]

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

Definition at line 629 of file strong_type.h.

629: 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 643 of file strong_type.h.

643: 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 669 of file strong_type.h.

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

◆ begin() [2/2]

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

Definition at line 667 of file strong_type.h.

667{ 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 661 of file strong_type.h.

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

◆ data() [2/2]

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

◆ empty()

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

Definition at line 665 of file strong_type.h.

665{ 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 673 of file strong_type.h.

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

◆ end() [2/2]

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

Definition at line 671 of file strong_type.h.

671{ 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 657 of file strong_type.h.

657{ 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 652 of file strong_type.h.

652{ 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 675 of file strong_type.h.

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

◆ size()


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