Botan 3.13.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&= (CT::Choice other) noexcept
constexpr bitrefoperator= (bitref &&bit) noexcept
constexpr bitrefoperator= (bool bit) noexcept
constexpr bitrefoperator= (const bitref &bit) noexcept
constexpr bitrefoperator= (CT::Choice bit) noexcept
constexpr bitrefoperator^= (bool other) noexcept
constexpr bitrefoperator^= (CT::Choice other) noexcept
constexpr bitrefoperator|= (bool other) noexcept
constexpr bitrefoperator|= (CT::Choice 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 322 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 289 of file bitvector.h.

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

◆ as_choice()

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

Definition at line 293 of file bitvector.h.

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

◆ flip()

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

Definition at line 340 of file bitvector.h.

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

References bitref().

◆ is_set()

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

Definition at line 286 of file bitvector.h.

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

◆ operator bool()

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

Definition at line 284 of file bitvector.h.

284{ return is_set(); }

◆ operator&=() [1/2]

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

Definition at line 365 of file bitvector.h.

365 {
366 this->m_block &= ~CT::Mask<BlockT>::expand(other).if_not_set_return(this->m_mask);
367 return *this;
368 }

References bitref().

◆ operator&=() [2/2]

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

Definition at line 370 of file bitvector.h.

370 {
371 this->m_block &= ~CT::Mask<BlockT>::from_choice(other).if_not_set_return(this->m_mask);
372 return *this;
373 }

References bitref().

◆ operator=() [1/4]

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

Definition at line 361 of file bitvector.h.

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

References bitref().

◆ operator=() [2/4]

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

Definition at line 347 of file bitvector.h.

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

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

◆ operator=() [3/4]

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

Definition at line 359 of file bitvector.h.

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

References bitref().

◆ operator=() [4/4]

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

Definition at line 353 of file bitvector.h.

353 {
355 this->m_block = mask.select(this->m_mask | this->m_block, this->m_block & ~this->m_mask);
356 return *this;
357 }
static constexpr Mask< T > from_choice(Choice c)
Definition ct_utils.h:402

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

◆ operator^=() [1/2]

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

Definition at line 385 of file bitvector.h.

385 {
386 this->m_block ^= CT::Mask<BlockT>::expand(other).if_set_return(this->m_mask);
387 return *this;
388 }

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

◆ operator^=() [2/2]

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

Definition at line 390 of file bitvector.h.

390 {
391 this->m_block ^= CT::Mask<BlockT>::from_choice(other).if_set_return(this->m_mask);
392 return *this;
393 }

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

◆ operator|=() [1/2]

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

Definition at line 375 of file bitvector.h.

375 {
376 this->m_block |= CT::Mask<BlockT>::expand(other).if_set_return(this->m_mask);
377 return *this;
378 }

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

◆ operator|=() [2/2]

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

Definition at line 380 of file bitvector.h.

380 {
381 this->m_block |= CT::Mask<BlockT>::from_choice(other).if_set_return(this->m_mask);
382 return *this;
383 }

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

◆ set()

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

Definition at line 330 of file bitvector.h.

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

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

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

References bitref().

Member Data Documentation

◆ m_block

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

Definition at line 298 of file bitvector.h.

◆ m_mask

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

Definition at line 299 of file bitvector.h.


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