Botan 3.6.1
Crypto and TLS for C&
Botan::Strong< T, TagTypeT, Capabilities > Class Template Reference

#include <strong_type.h>

Inheritance diagram for Botan::Strong< T, TagTypeT, Capabilities >:
Botan::detail::Strong_Adapter< T > Botan::detail::Strong_Base< T > Botan::detail::Strong_Base< T >

Public Types

using const_iterator = typename T::const_iterator
 
using const_pointer = typename T::const_pointer
 
using iterator = typename T::iterator
 
using pointer = typename T::pointer
 
using size_type = typename T::size_type
 
using value_type = typename T::value_type
 
using wrapped_type = T
 

Public Member Functions

decltype(auto) begin () const noexcept(noexcept(this->get().begin()))
 
decltype(auto) begin () noexcept(noexcept(this->get().begin()))
 
decltype(auto) cbegin () const noexcept(noexcept(this->get().cbegin()))
 
decltype(auto) cbegin () noexcept(noexcept(this->get().cbegin()))
 
decltype(auto) cend () const noexcept(noexcept(this->get().cend()))
 
decltype(auto) cend () noexcept(noexcept(this->get().cend()))
 
decltype(auto) data () const noexcept(noexcept(this->get().data()))
 
decltype(auto) data () noexcept(noexcept(this->get().data()))
 
bool empty () const noexcept(noexcept(this->get().empty()))
 
decltype(auto) end () const noexcept(noexcept(this->get().end()))
 
decltype(auto) end () noexcept(noexcept(this->get().end()))
 
constexpr Tget () &
 
constexpr T && get () &&
 
constexpr const Tget () const &
 
constexpr const T && get () const &&
 
decltype(auto) operator[] (size_type i) const noexcept(noexcept(this->get().operator[](i)))
 
decltype(auto) operator[] (size_type i) noexcept(noexcept(this->get().operator[](i)))
 
void reserve (size_type size) noexcept(noexcept(this->get().reserve(size)))
 
void resize (size_type size) noexcept(noexcept(this->get().resize(size)))
 
size_type size () const noexcept(noexcept(this->get().size()))
 

Static Public Member Functions

template<typename CapabilityT >
static constexpr bool has_capability ()
 

Detailed Description

template<typename T, typename TagTypeT, typename... Capabilities>
class Botan::Strong< T, TagTypeT, Capabilities >

Strong types can be used as wrappers around common types to provide compile time semantics. They usually contribute to more maintainable and less error-prone code especially when dealing with function parameters.

Internally, this provides adapters so that the wrapping strong type behaves as much as the underlying type as possible and desirable.

This implementation was inspired by: https://stackoverflow.com/a/69030899

Definition at line 172 of file strong_type.h.

Member Typedef Documentation

◆ const_iterator

template<concepts::container T>
using Botan::detail::Strong_Adapter< T >::const_iterator = typename T::const_iterator
inherited

Definition at line 77 of file strong_type.h.

◆ const_pointer

template<concepts::container T>
using Botan::detail::Strong_Adapter< T >::const_pointer = typename T::const_pointer
inherited

Definition at line 79 of file strong_type.h.

◆ iterator

template<concepts::container T>
using Botan::detail::Strong_Adapter< T >::iterator = typename T::iterator
inherited

Definition at line 76 of file strong_type.h.

◆ pointer

template<concepts::container T>
using Botan::detail::Strong_Adapter< T >::pointer = typename T::pointer
inherited

Definition at line 78 of file strong_type.h.

◆ size_type

template<concepts::container T>
using Botan::detail::Strong_Adapter< T >::size_type = typename T::size_type
inherited

Definition at line 75 of file strong_type.h.

◆ value_type

template<concepts::container T>
using Botan::detail::Strong_Adapter< T >::value_type = typename T::value_type
inherited

Definition at line 74 of file strong_type.h.

◆ wrapped_type

template<typename T >
using Botan::detail::Strong_Base< T >::wrapped_type = T
inherited

Definition at line 39 of file strong_type.h.

Member Function Documentation

◆ begin() [1/2]

template<concepts::container T>
decltype(auto) Botan::detail::Strong_Adapter< T >::begin ( ) const
inlinenoexceptinherited

Definition at line 105 of file strong_type.h.

105{ return this->get().begin(); }
constexpr T & get() &
Definition strong_type.h:50

References Botan::detail::Strong_Base< T >::get().

◆ begin() [2/2]

template<concepts::container T>
decltype(auto) Botan::detail::Strong_Adapter< T >::begin ( )
inlinenoexceptinherited

Definition at line 103 of file strong_type.h.

103{ return this->get().begin(); }

References Botan::detail::Strong_Base< T >::get().

Referenced by Botan::encode_point(), and Botan::wots_sign_and_pkgen().

◆ cbegin() [1/2]

template<concepts::container T>
decltype(auto) Botan::detail::Strong_Adapter< T >::cbegin ( ) const
inlinenoexceptinherited

Definition at line 113 of file strong_type.h.

113{ return this->get().cbegin(); }

References Botan::detail::Strong_Base< T >::get().

◆ cbegin() [2/2]

template<concepts::container T>
decltype(auto) Botan::detail::Strong_Adapter< T >::cbegin ( )
inlinenoexceptinherited

Definition at line 111 of file strong_type.h.

111{ return this->get().cbegin(); }

References Botan::detail::Strong_Base< T >::get().

◆ cend() [1/2]

template<concepts::container T>
decltype(auto) Botan::detail::Strong_Adapter< T >::cend ( ) const
inlinenoexceptinherited

Definition at line 117 of file strong_type.h.

117{ return this->get().cend(); }

References Botan::detail::Strong_Base< T >::get().

◆ cend() [2/2]

template<concepts::container T>
decltype(auto) Botan::detail::Strong_Adapter< T >::cend ( )
inlinenoexceptinherited

Definition at line 115 of file strong_type.h.

115{ return this->get().cend(); }

References Botan::detail::Strong_Base< T >::get().

◆ data() [1/2]

template<concepts::container T>
decltype(auto) Botan::detail::Strong_Adapter< T >::data ( ) const
inlinenoexceptinherited

Definition at line 127 of file strong_type.h.

129 {
130 return this->get().data();
131 }

References Botan::detail::Strong_Base< T >::get().

◆ data() [2/2]

template<concepts::container T>
decltype(auto) Botan::detail::Strong_Adapter< T >::data ( )
inlinenoexceptinherited

Definition at line 121 of file strong_type.h.

123 {
124 return this->get().data();
125 }

References Botan::detail::Strong_Base< T >::get().

Referenced by Botan::FrodoMatrix::serialize().

◆ empty()

template<concepts::container T>
bool Botan::detail::Strong_Adapter< T >::empty ( ) const
inlinenoexceptinherited

Definition at line 133 of file strong_type.h.

135 {
136 return this->get().empty();
137 }

References Botan::detail::Strong_Base< T >::get().

◆ end() [1/2]

template<concepts::container T>
decltype(auto) Botan::detail::Strong_Adapter< T >::end ( ) const
inlinenoexceptinherited

Definition at line 109 of file strong_type.h.

109{ return this->get().end(); }

References Botan::detail::Strong_Base< T >::get().

◆ end() [2/2]

template<concepts::container T>
decltype(auto) Botan::detail::Strong_Adapter< T >::end ( )
inlinenoexceptinherited

Definition at line 107 of file strong_type.h.

107{ return this->get().end(); }

References Botan::detail::Strong_Base< T >::get().

Referenced by Botan::encode_point().

◆ get() [1/4]

template<typename T >
T & Botan::detail::Strong_Base< T >::get ( ) &
inlineconstexprinherited

Definition at line 50 of file strong_type.h.

50{ return m_value; }

Referenced by Botan::detail::Strong_Adapter< T >::begin(), Botan::detail::Strong_Adapter< T >::begin(), Botan::detail::Strong_Adapter< T >::cbegin(), Botan::detail::Strong_Adapter< T >::cbegin(), Botan::detail::Strong_Adapter< T >::cend(), Botan::detail::Strong_Adapter< T >::cend(), Botan::chain_lengths(), Botan::compute_root(), Botan::detail::Strong_Adapter< T >::data(), Botan::detail::Strong_Adapter< T >::data(), Botan::detail::Strong_Adapter< T >::empty(), Botan::detail::Strong_Adapter< T >::end(), Botan::detail::Strong_Adapter< T >::end(), Botan::ht_sign(), Botan::ht_verify(), Botan::LMOTS_Private_Key::LMOTS_Private_Key(), Botan::operator&(), Botan::operator&(), Botan::operator&=(), Botan::operator&=(), Botan::operator*(), Botan::operator*(), Botan::operator*=(), Botan::operator*=(), Botan::operator+(), Botan::operator+(), Botan::operator++(), Botan::operator++(), Botan::operator+=(), Botan::operator+=(), Botan::operator-(), Botan::operator-(), Botan::operator--(), Botan::operator--(), Botan::operator-=(), Botan::operator-=(), Botan::operator/(), Botan::operator/(), Botan::operator/=(), Botan::operator/=(), Botan::operator<<(), Botan::operator<<(), Botan::operator<<(), Botan::operator<<=(), Botan::operator<<=(), Botan::operator<=>(), Botan::operator<=>(), Botan::operator==(), Botan::operator==(), Botan::operator>>(), Botan::operator>>(), Botan::operator>>=(), Botan::operator>>=(), Botan::detail::Strong_Adapter< T >::operator[](), Botan::detail::Strong_Adapter< T >::operator[](), Botan::operator^(), Botan::operator^(), Botan::operator^=(), Botan::operator^=(), Botan::operator|(), Botan::operator|(), Botan::operator|=(), Botan::operator|=(), Botan::HSS_LMS_Params::params_at_level(), Botan::TLS::Cipher_State::psk(), Botan::detail::Strong_Adapter< T >::reserve(), Botan::detail::Strong_Adapter< T >::resize(), Botan::TLS::New_Session_Ticket_12::serialize(), Botan::TLS::New_Session_Ticket_13::serialize(), Botan::Sphincs_Address::set_chain_address(), Botan::Sphincs_Address::set_hash_address(), Botan::Sphincs_Address::set_keypair_address(), Botan::Sphincs_Address::set_layer_address(), Botan::Sphincs_Address::set_tree_address(), Botan::Sphincs_Address::set_tree_height(), Botan::Sphincs_Address::set_tree_index(), Botan::HSS_LMS_PrivateKeyInternal::sign(), Botan::LMS_PrivateKey::sign_and_get_pk(), Botan::HSS_Signature::signed_pub_key(), Botan::detail::Strong_Adapter< T >::size(), Botan::treehash(), Botan::wots_public_key_from_signature(), and Botan::x448().

◆ get() [2/4]

template<typename T >
T && Botan::detail::Strong_Base< T >::get ( ) &&
inlineconstexprinherited

Definition at line 54 of file strong_type.h.

54{ return std::move(m_value); }

◆ get() [3/4]

template<typename T >
const T & Botan::detail::Strong_Base< T >::get ( ) const &
inlineconstexprinherited

Definition at line 52 of file strong_type.h.

52{ return m_value; }

◆ get() [4/4]

template<typename T >
const T && Botan::detail::Strong_Base< T >::get ( ) const &&
inlineconstexprinherited

Definition at line 56 of file strong_type.h.

56{ return std::move(m_value); }

◆ has_capability()

template<typename T , typename TagTypeT , typename... Capabilities>
template<typename CapabilityT >
static constexpr bool Botan::Strong< T, TagTypeT, Capabilities >::has_capability ( )
inlinestaticconstexpr

Definition at line 177 of file strong_type.h.

177 {
178 return (std::is_same_v<CapabilityT, Capabilities> || ...);
179 }

◆ operator[]() [1/2]

template<concepts::container T>
decltype(auto) Botan::detail::Strong_Adapter< T >::operator[] ( size_type i) const
inlinenoexceptinherited

Definition at line 151 of file strong_type.h.

151 {
152 return this->get()[i];
153 }

References Botan::detail::Strong_Base< T >::get().

◆ operator[]() [2/2]

template<concepts::container T>
decltype(auto) Botan::detail::Strong_Adapter< T >::operator[] ( size_type i)
inlinenoexceptinherited

Definition at line 155 of file strong_type.h.

155{ return this->get()[i]; }

References Botan::detail::Strong_Base< T >::get().

◆ reserve()

template<concepts::container T>
void Botan::detail::Strong_Adapter< T >::reserve ( size_type size)
inlinenoexceptinherited

Definition at line 145 of file strong_type.h.

147 {
148 this->get().reserve(size);
149 }
size_type size() const noexcept(noexcept(this->get().size()))

References Botan::detail::Strong_Base< T >::get().

◆ resize()

template<concepts::container T>
void Botan::detail::Strong_Adapter< T >::resize ( size_type size)
inlinenoexceptinherited

Definition at line 139 of file strong_type.h.

141 {
142 this->get().resize(size);
143 }

References Botan::detail::Strong_Base< T >::get().

◆ size()

template<concepts::container T>
size_type Botan::detail::Strong_Adapter< T >::size ( ) const
inlinenoexceptinherited

Definition at line 119 of file strong_type.h.

119{ return this->get().size(); }

References Botan::detail::Strong_Base< T >::get().


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