9#ifndef BOTAN_STRONG_TYPE_H_
10#define BOTAN_STRONG_TYPE_H_
15#include <botan/concepts.h>
30template <
typename CapabilityT,
typename... Tags>
50 T&
get() {
return m_value; }
52 const T&
get()
const {
return m_value; }
61template <std::
integral T>
67template <concepts::container T>
88 template <
typename InputIt>
95 requires(std::same_as<T, std::string>)
99 decltype(
auto)
begin()
noexcept(
noexcept(this->
get().begin())) {
return this->
get().begin(); }
101 decltype(
auto)
begin()
const noexcept(
noexcept(this->
get().begin())) {
return this->
get().begin(); }
103 decltype(
auto)
end()
noexcept(
noexcept(this->
get().end())) {
return this->
get().end(); }
105 decltype(
auto)
end()
const noexcept(
noexcept(this->
get().end())) {
return this->
get().end(); }
107 decltype(
auto)
cbegin()
noexcept(
noexcept(this->
get().cbegin())) {
return this->
get().cbegin(); }
109 decltype(
auto)
cbegin()
const noexcept(
noexcept(this->
get().cbegin())) {
return this->
get().cbegin(); }
111 decltype(
auto)
cend()
noexcept(
noexcept(this->
get().cend())) {
return this->
get().cend(); }
113 decltype(
auto)
cend()
const noexcept(
noexcept(this->
get().cend())) {
return this->
get().cend(); }
117 decltype(
auto)
data()
noexcept(
noexcept(this->
get().data()))
120 return this->
get().data();
123 decltype(
auto)
data()
const noexcept(
noexcept(this->
get().data()))
126 return this->
get().data();
129 bool empty() const noexcept(noexcept(this->
get().empty()))
130 requires(concepts::has_empty<
T>)
132 return this->
get().empty();
138 this->
get().resize(size);
141 decltype(
auto)
operator[](
size_type i)
const noexcept(
noexcept(this->
get().operator[](i))) {
142 return this->
get()[i];
145 decltype(
auto)
operator[](
size_type i)
noexcept(
noexcept(this->
get().operator[](i))) {
return this->
get()[i]; }
161template <
typename T,
typename TagTypeT,
typename... Capabilities>
167 using Tag = TagTypeT;
170template <
typename T,
typename... Tags>
173 return os << v.
get();
176template <
typename T,
typename... Tags>
177 requires(std::equality_comparable<T>)
bool
179 return lhs.
get() == rhs.
get();
182template <
typename T,
typename... Tags>
183 requires(std::three_way_comparable<T>)
185 return lhs.
get() <=> rhs.
get();
188template <std::integral T1, std::integral T2,
typename... Tags>
190 return a <=> b.
get();
193template <std::integral T1, std::integral T2,
typename... Tags>
195 return a.
get() <=> b;
198template <std::integral T1, std::integral T2,
typename... Tags>
203template <std::integral T1, std::integral T2,
typename... Tags>
208template <std::integral T1, std::integral T2,
typename... Tags>
214template <std::integral T1, std::integral T2,
typename... Tags>
220template <std::integral
T,
typename... Tags>
225template <std::integral T1, std::integral T2,
typename... Tags>
231template <std::integral T1, std::integral T2,
typename... Tags>
237template <std::integral
T,
typename... Tags>
242template <std::integral T1, std::integral T2,
typename... Tags>
248template <std::integral T1, std::integral T2,
typename... Tags>
254template <std::integral
T,
typename... Tags>
259template <std::integral T1, std::integral T2,
typename... Tags>
265template <std::integral T1, std::integral T2,
typename... Tags>
271template <std::integral
T,
typename... Tags>
276template <std::integral T1, std::integral T2,
typename... Tags>
282template <std::integral T1, std::integral T2,
typename... Tags>
288template <std::integral
T,
typename... Tags>
293template <std::integral T1, std::integral T2,
typename... Tags>
299template <std::integral T1, std::integral T2,
typename... Tags>
305template <std::integral
T,
typename... Tags>
310template <std::integral T1, std::integral T2,
typename... Tags>
316template <std::integral T1, std::integral T2,
typename... Tags>
322template <std::integral
T,
typename... Tags>
327template <std::integral T1, std::integral T2,
typename... Tags>
330 return Strong<T2, Tags...>(a >> b.
get());
333template <std::integral T1, std::integral T2,
typename... Tags>
336 return Strong<T1, Tags...>(a.
get() >> b);
339template <std::integral
T,
typename... Tags>
344template <std::integral T1, std::integral T2,
typename... Tags>
347 return Strong<T2, Tags...>(a << b.
get());
350template <std::integral T1, std::integral T2,
typename... Tags>
353 return Strong<T1, Tags...>(a.
get() << b);
356template <std::integral
T,
typename... Tags>
361template <std::integral T1, std::integral T2,
typename... Tags>
368template <std::integral
T,
typename... Tags>
374template <std::integral T1, std::integral T2,
typename... Tags>
381template <std::integral
T,
typename... Tags>
387template <std::integral T1, std::integral T2,
typename... Tags>
394template <std::integral
T,
typename... Tags>
400template <std::integral T1, std::integral T2,
typename... Tags>
407template <std::integral
T,
typename... Tags>
413template <std::integral T1, std::integral T2,
typename... Tags>
420template <std::integral
T,
typename... Tags>
426template <std::integral T1, std::integral T2,
typename... Tags>
433template <std::integral
T,
typename... Tags>
439template <std::integral T1, std::integral T2,
typename... Tags>
446template <std::integral
T,
typename... Tags>
452template <std::integral T1, std::integral T2,
typename... Tags>
459template <std::integral
T,
typename... Tags>
465template <std::integral T1, std::integral T2,
typename... Tags>
472template <std::integral
T,
typename... Tags>
478template <std::integral
T,
typename... Tags>
485template <std::integral
T,
typename... Tags>
491template <std::integral
T,
typename... Tags>
498template <std::integral
T,
typename... Tags>
519template <concepts::contiguous_strong_type T>
521 using underlying_span = std::
522 conditional_t<std::is_const_v<T>, std::span<const typename T::value_type>, std::span<typename T::value_type>>;
527 using iterator =
typename underlying_span::iterator;
528 using pointer =
typename underlying_span::pointer;
548 typename = std::enable_if_t<std::is_same_v<T2, std::remove_const_t<T>>>>
558 underlying_span
get()
const {
return m_span; }
563 underlying_span
get() {
return m_span; }
565 decltype(
auto)
data()
noexcept(
noexcept(this->m_span.data())) {
return this->m_span.data(); }
567 decltype(
auto)
data()
const noexcept(
noexcept(this->m_span.data())) {
return this->m_span.data(); }
569 decltype(
auto)
size()
const noexcept(
noexcept(this->m_span.size())) {
return this->m_span.size(); }
571 bool empty() const noexcept(noexcept(this->m_span.
empty())) {
return this->m_span.empty(); }
573 decltype(
auto)
begin()
noexcept(
noexcept(this->m_span.begin())) {
return this->m_span.begin(); }
575 decltype(
auto)
begin()
const noexcept(
noexcept(this->m_span.begin())) {
return this->m_span.begin(); }
577 decltype(
auto)
end()
noexcept(
noexcept(this->m_span.end())) {
return this->m_span.end(); }
579 decltype(
auto)
end()
const noexcept(
noexcept(this->m_span.end())) {
return this->m_span.end(); }
581 decltype(
auto)
operator[](
typename underlying_span::size_type i)
const noexcept {
return this->m_span[i]; }
584 underlying_span m_span;
typename underlying_span::size_type size_type
decltype(auto) begin() noexcept(noexcept(this->m_span.begin()))
decltype(auto) data() noexcept(noexcept(this->m_span.data()))
underlying_span get() const
StrongSpan(const StrongSpan< T2 > &other)
typename underlying_span::value_type value_type
decltype(auto) begin() const noexcept(noexcept(this->m_span.begin()))
StrongSpan(const StrongSpan &other)=default
decltype(auto) end() noexcept(noexcept(this->m_span.end()))
StrongSpan(underlying_span span)
typename underlying_span::const_pointer const_pointer
bool empty() const noexcept(noexcept(this->m_span.empty()))
typename underlying_span::pointer pointer
decltype(auto) data() const noexcept(noexcept(this->m_span.data()))
decltype(auto) end() const noexcept(noexcept(this->m_span.end()))
typename underlying_span::iterator iterator
decltype(auto) size() const noexcept(noexcept(this->m_span.size()))
decltype(auto) data() const noexcept(noexcept(this->get().data()))
typename T::size_type size_type
Strong_Adapter(const char *str)
decltype(auto) end() const noexcept(noexcept(this->get().end()))
Strong_Adapter(size_t size)
void resize(size_type size) noexcept(noexcept(this->get().resize(size)))
typename T::iterator iterator
decltype(auto) begin() noexcept(noexcept(this->get().begin()))
size_type size() const noexcept(noexcept(this->get().size()))
decltype(auto) cbegin() noexcept(noexcept(this->get().cbegin()))
typename T::const_pointer const_pointer
typename T::pointer pointer
typename T::value_type value_type
decltype(auto) begin() const noexcept(noexcept(this->get().begin()))
decltype(auto) cend() const noexcept(noexcept(this->get().cend()))
decltype(auto) end() noexcept(noexcept(this->get().end()))
typename T::const_iterator const_iterator
bool empty() const noexcept(noexcept(this->get().empty()))
decltype(auto) data() noexcept(noexcept(this->get().data()))
Strong_Adapter(std::span< const value_type > span)
decltype(auto) cend() noexcept(noexcept(this->get().cend()))
decltype(auto) cbegin() const noexcept(noexcept(this->get().cbegin()))
Strong_Adapter(InputIt begin, InputIt end)
Strong_Base(Strong_Base &&) noexcept=default
Strong_Base(const Strong_Base &)=default
constexpr bool has_capability
ASN1_Type operator|(ASN1_Type x, ASN1_Type y)
BigInt operator*(const BigInt &x, const BigInt &y)
constexpr auto operator>>=(Strong< T1, Tags... > &a, T2 b)
OctetString operator^(const OctetString &k1, const OctetString &k2)
OctetString operator+(const OctetString &k1, const OctetString &k2)
constexpr auto operator++(Strong< T, Tags... > &a, int)
std::ostream & operator<<(std::ostream &out, const OID &oid)
BigInt operator/(const BigInt &x, const BigInt &y)
BigInt operator-(const BigInt &x, const BigInt &y)
constexpr auto operator/=(Strong< T1, Tags... > &a, T2 b)
constexpr auto operator|=(Strong< T1, Tags... > &a, T2 b)
constexpr auto operator<<=(Strong< T1, Tags... > &a, T2 b)
constexpr auto operator&=(Strong< T1, Tags... > &a, T2 b)
bool operator==(const AlgorithmIdentifier &a1, const AlgorithmIdentifier &a2)
std::vector< uint8_t, Alloc > & operator^=(std::vector< uint8_t, Alloc > &out, const std::vector< uint8_t, Alloc2 > &in)
std::vector< T, Alloc > & operator+=(std::vector< T, Alloc > &out, const std::vector< T, Alloc2 > &in)
int operator>>(int fd, Pipe &pipe)
constexpr auto operator-=(Strong< T1, Tags... > &a, T2 b)
constexpr auto operator--(Strong< T, Tags... > &a, int)
auto operator<=>(const Strong< T, Tags... > &lhs, const Strong< T, Tags... > &rhs)
ECIES_Flags operator&(ECIES_Flags a, ECIES_Flags b)
constexpr auto operator*=(Strong< T1, Tags... > &a, T2 b)