Botan 3.9.0
Crypto and TLS for C&
Botan::bitvector_base< AllocatorT >::bitref< BlockT > Class Template Reference

#include <bitvector.h>

Public Member Functions

constexpr T as () const noexcept
constexpr CT::Choice as_choice () const noexcept
 bitref (bitref &&) noexcept=default
 bitref (const bitref &) noexcept=default
constexpr bitrefflip () noexcept
constexpr bool is_set () const noexcept
constexpr operator bool () const noexcept
constexpr bitrefoperator&= (bool other) noexcept
constexpr bitrefoperator= (bitref &&bit) noexcept
constexpr bitrefoperator= (bool bit) noexcept
constexpr bitrefoperator= (const bitref &bit) noexcept
constexpr bitrefoperator^= (bool other) noexcept
constexpr bitrefoperator|= (bool other) noexcept
constexpr bitrefset () noexcept
constexpr bitrefunset () noexcept
 ~bitref ()=default

Protected Attributes

BlockT & m_block
BlockT m_mask

Detailed Description

template<template< typename > typename AllocatorT>
template<typename BlockT>
requires (!std::is_const_v<BlockT>)
class Botan::bitvector_base< AllocatorT >::bitref< BlockT >

Wraps a modifiable reference into the bitvector. Bit may be accessed and modified (e.g. flipped or XOR'ed).

Constant-time operations are used for the bit manipulations. The location of the bit in the bit vector may be leaked, though.

Definition at line 321 of file bitvector.h.

Constructor & Destructor Documentation

◆ ~bitref()

template<template< typename > typename AllocatorT>
template<typename BlockT>
Botan::bitvector_base< AllocatorT >::bitref< BlockT >::~bitref ( )
default

◆ bitref() [1/2]

template<template< typename > typename AllocatorT>
template<typename BlockT>
Botan::bitvector_base< AllocatorT >::bitref< BlockT >::bitref ( const bitref< BlockT > & )
defaultnoexcept

◆ bitref() [2/2]

template<template< typename > typename AllocatorT>
template<typename BlockT>
Botan::bitvector_base< AllocatorT >::bitref< BlockT >::bitref ( bitref< BlockT > && )
defaultnoexcept

References bitref().

Member Function Documentation

◆ as()

T Botan::bitvector_base< AllocatorT >::bitref_base< BlockT >::as ( ) const
inlineconstexprnoexcept

Definition at line 288 of file bitvector.h.

288 {
289 return static_cast<T>(is_set());
290 }

◆ as_choice()

CT::Choice Botan::bitvector_base< AllocatorT >::bitref_base< BlockT >::as_choice ( ) const
inlineconstexprnoexcept

Definition at line 292 of file bitvector.h.

292 {
293 return CT::Choice::from_int(static_cast<BlockT>(m_block & m_mask));
294 }
static constexpr Choice from_int(T v)
Definition ct_utils.h:314

◆ flip()

template<template< typename > typename AllocatorT>
template<typename BlockT>
bitref & Botan::bitvector_base< AllocatorT >::bitref< BlockT >::flip ( )
inlineconstexprnoexcept

Definition at line 339 of file bitvector.h.

339 {
340 this->m_block ^= this->m_mask;
341 return *this;
342 }

References bitref().

◆ is_set()

bool Botan::bitvector_base< AllocatorT >::bitref_base< BlockT >::is_set ( ) const
inlineconstexprnoexcept

Definition at line 285 of file bitvector.h.

285{ return (m_block & m_mask) > 0; }

◆ operator bool()

Botan::bitvector_base< AllocatorT >::bitref_base< BlockT >::operator bool ( ) const
inlineconstexprnoexcept

Definition at line 283 of file bitvector.h.

283{ return is_set(); }

◆ operator&=()

template<template< typename > typename AllocatorT>
template<typename BlockT>
bitref & Botan::bitvector_base< AllocatorT >::bitref< BlockT >::operator&= ( bool other)
inlineconstexprnoexcept

Definition at line 358 of file bitvector.h.

358 {
359 this->m_block &= ~CT::Mask<BlockT>::expand(other).if_not_set_return(this->m_mask);
360 return *this;
361 }

References bitref().

◆ operator=() [1/3]

template<template< typename > typename AllocatorT>
template<typename BlockT>
bitref & Botan::bitvector_base< AllocatorT >::bitref< BlockT >::operator= ( bitref< BlockT > && bit)
inlineconstexprnoexcept

Definition at line 354 of file bitvector.h.

354{ return *this = bit.is_set(); }

References bitref().

◆ operator=() [2/3]

template<template< typename > typename AllocatorT>
template<typename BlockT>
bitref & Botan::bitvector_base< AllocatorT >::bitref< BlockT >::operator= ( bool bit)
inlineconstexprnoexcept

Definition at line 346 of file bitvector.h.

346 {
347 this->m_block =
348 CT::Mask<BlockT>::expand(bit).select(this->m_mask | this->m_block, this->m_block & ~this->m_mask);
349 return *this;
350 }
static constexpr Mask< T > expand(T v)
Definition ct_utils.h:420

References bitref(), and Botan::CT::Mask< T >::expand().

◆ operator=() [3/3]

template<template< typename > typename AllocatorT>
template<typename BlockT>
bitref & Botan::bitvector_base< AllocatorT >::bitref< BlockT >::operator= ( const bitref< BlockT > & bit)
inlineconstexprnoexcept

Definition at line 352 of file bitvector.h.

352{ return *this = bit.is_set(); }

References bitref().

◆ operator^=()

template<template< typename > typename AllocatorT>
template<typename BlockT>
bitref & Botan::bitvector_base< AllocatorT >::bitref< BlockT >::operator^= ( bool other)
inlineconstexprnoexcept

Definition at line 368 of file bitvector.h.

368 {
369 this->m_block ^= CT::Mask<BlockT>::expand(other).if_set_return(this->m_mask);
370 return *this;
371 }

References bitref(), and Botan::CT::Mask< T >::expand().

◆ operator|=()

template<template< typename > typename AllocatorT>
template<typename BlockT>
bitref & Botan::bitvector_base< AllocatorT >::bitref< BlockT >::operator|= ( bool other)
inlineconstexprnoexcept

Definition at line 363 of file bitvector.h.

363 {
364 this->m_block |= CT::Mask<BlockT>::expand(other).if_set_return(this->m_mask);
365 return *this;
366 }

References bitref(), and Botan::CT::Mask< T >::expand().

◆ set()

template<template< typename > typename AllocatorT>
template<typename BlockT>
bitref & Botan::bitvector_base< AllocatorT >::bitref< BlockT >::set ( )
inlineconstexprnoexcept

Definition at line 329 of file bitvector.h.

329 {
330 this->m_block |= this->m_mask;
331 return *this;
332 }

References bitref(), and set().

Referenced by set().

◆ unset()

template<template< typename > typename AllocatorT>
template<typename BlockT>
bitref & Botan::bitvector_base< AllocatorT >::bitref< BlockT >::unset ( )
inlineconstexprnoexcept

Definition at line 334 of file bitvector.h.

334 {
335 this->m_block &= ~this->m_mask;
336 return *this;
337 }

References bitref().

Member Data Documentation

◆ m_block

BlockT& Botan::bitvector_base< AllocatorT >::bitref_base< BlockT >::m_block
protected

Definition at line 297 of file bitvector.h.

◆ m_mask

BlockT Botan::bitvector_base< AllocatorT >::bitref_base< BlockT >::m_mask
protected

Definition at line 298 of file bitvector.h.


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