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

#include <bitvector.h>

Public Member Functions

template<std::integral T>
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 319 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

Member Function Documentation

◆ as()

template<template< typename > typename AllocatorT>
template<typename BlockT >
template<std::integral T>
T Botan::bitvector_base< AllocatorT >::bitref_base< BlockT >::as ( ) const
inlineconstexprnoexceptinherited

Definition at line 286 of file bitvector.h.

286 {
287 return static_cast<T>(is_set());
288 }
FE_25519 T
Definition ge.cpp:34

◆ as_choice()

template<template< typename > typename AllocatorT>
template<typename BlockT >
CT::Choice Botan::bitvector_base< AllocatorT >::bitref_base< BlockT >::as_choice ( ) const
inlineconstexprnoexceptinherited

Definition at line 290 of file bitvector.h.

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

◆ flip()

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

Definition at line 337 of file bitvector.h.

337 {
338 this->m_block ^= this->m_mask;
339 return *this;
340 }

◆ is_set()

template<template< typename > typename AllocatorT>
template<typename BlockT >
bool Botan::bitvector_base< AllocatorT >::bitref_base< BlockT >::is_set ( ) const
inlineconstexprnoexceptinherited

Definition at line 283 of file bitvector.h.

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

◆ operator bool()

template<template< typename > typename AllocatorT>
template<typename BlockT >
Botan::bitvector_base< AllocatorT >::bitref_base< BlockT >::operator bool ( ) const
inlineconstexprnoexceptinherited

Definition at line 281 of file bitvector.h.

281{ 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 356 of file bitvector.h.

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

◆ 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 352 of file bitvector.h.

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

◆ 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 344 of file bitvector.h.

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

References 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 350 of file bitvector.h.

350{ return *this = bit.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 366 of file bitvector.h.

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

References 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 361 of file bitvector.h.

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

References 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 327 of file bitvector.h.

327 {
328 this->m_block |= this->m_mask;
329 return *this;
330 }

◆ unset()

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

Definition at line 332 of file bitvector.h.

332 {
333 this->m_block &= ~this->m_mask;
334 return *this;
335 }

Member Data Documentation

◆ m_block

template<template< typename > typename AllocatorT>
template<typename BlockT >
BlockT& Botan::bitvector_base< AllocatorT >::bitref_base< BlockT >::m_block
protectedinherited

Definition at line 295 of file bitvector.h.

◆ m_mask

template<template< typename > typename AllocatorT>
template<typename BlockT >
BlockT Botan::bitvector_base< AllocatorT >::bitref_base< BlockT >::m_mask
protectedinherited

Definition at line 296 of file bitvector.h.


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