Universal Numbers Library C++ API
sw::universal -- header-only custom arithmetic types (posit, cfloat, lns, fixpnt, dd/qd, and more)
Loading...
Searching...
No Matches
universal_bitset::bitset< Nb > Class Template Reference

The bitset class represents a fixed-size sequence of bits. More...

#include <ubb.h>

Inheritance diagram for universal_bitset::bitset< Nb >:
universal_bitset::BaseBitset< UBB_WORDS(Nb)>

Classes

class  reference
 This encapsulates the concept of a single bit. More...

Public Member Functions

constexpr bitset () noexcept
 All bits set to zero.
constexpr bitset (unsigned long long val) noexcept
 Initial bits bitwise-copied from a single word (others set to zero).
template<class _CharT, class _Traits, class _Alloc>
 bitset (const std::basic_string< _CharT, _Traits, _Alloc > &s, size_t position=0)
 Use a subset of a string.
template<class _CharT, class _Traits, class _Alloc>
 bitset (const std::basic_string< _CharT, _Traits, _Alloc > &s, size_t position, size_t n)
 Use a subset of a string.
template<class _CharT, class _Traits, class _Alloc>
 bitset (const std::basic_string< _CharT, _Traits, _Alloc > &s, size_t position, size_t n, _CharT zero, _CharT one=_CharT('1'))
template<typename _CharT>
 bitset (const _CharT *str, typename std::basic_string< _CharT >::size_type n=std::basic_string< _CharT >::npos, _CharT zero=_CharT('0'), _CharT one=_CharT('1'))
 Construct from a character array.
bitset< Nb > & operator&= (const bitset< Nb > &rhs) noexcept
 Operations on bitsets.
bitset< Nb > & operator|= (const bitset< Nb > &rhs) noexcept
bitset< Nb > & operator^= (const bitset< Nb > &rhs) noexcept
bitset< Nb > & operator<<= (size_t position) noexcept
 Operations on bitsets.
bitset< Nb > & operator>>= (size_t position) noexcept
bitset< Nb > & Unchecked_set (size_t pos) noexcept
 These versions of single-bit set, reset, flip, and test are extensions from the SGI version.
bitset< Nb > & Unchecked_set (size_t pos, int val) noexcept
bitset< Nb > & Unchecked_reset (size_t pos) noexcept
bitset< Nb > & Unchecked_flip (size_t pos) noexcept
constexpr bool Unchecked_test (size_t pos) const noexcept
bitset< Nb > & set () noexcept
 Sets every bit to true.
bitset< Nb > & set (size_t position, bool val=true)
 Sets a given bit to a particular value.
bitset< Nb > & reset () noexcept
 Sets every bit to false.
bitset< Nb > & reset (size_t position)
 Sets a given bit to false.
bitset< Nb > & flip () noexcept
 Toggles every bit to its opposite value.
bitset< Nb > & flip (size_t position)
 Toggles a given bit to its opposite value.
bitset< Nb > operator~ () const noexcept
 See the no-argument flip().
reference operator[] (size_t position)
 Array-indexing support.
constexpr bool operator[] (size_t position) const
unsigned long to_ulong () const
 Returns a numerical interpretation of the bitset.
unsigned long long to_ullong () const
template<class _CharT, class _Traits, class _Alloc>
std::basic_string< _CharT, _Traits, _Alloc > to_string () const
 Returns a character interpretation of the bitset.
template<class _CharT, class _Traits, class _Alloc>
std::basic_string< _CharT, _Traits, _Alloc > to_string (_CharT zero, _CharT one=_CharT('1')) const
template<class _CharT, class _Traits>
std::basic_string< _CharT, _Traits, std::allocator< _CharT > > to_string () const
template<class _CharT, class _Traits>
std::basic_string< _CharT, _Traits, std::allocator< _CharT > > to_string (_CharT zero, _CharT one=_CharT('1')) const
template<class _CharT>
std::basic_string< _CharT, std::char_traits< _CharT >, std::allocator< _CharT > > to_string () const
template<class _CharT>
std::basic_string< _CharT, std::char_traits< _CharT >, std::allocator< _CharT > > to_string (_CharT zero, _CharT one=_CharT('1')) const
std::basic_string< char, std::char_traits< char >, std::allocator< char > > to_string () const
std::basic_string< char, std::char_traits< char >, std::allocator< char > > to_string (char zero, char one='1') const
template<class _CharT, class _Traits>
void M_copy_from_ptr (const _CharT *, size_t, size_t, size_t, _CharT, _CharT)
template<class _CharT, class _Traits, class _Alloc>
void M_copy_from_string (const std::basic_string< _CharT, _Traits, _Alloc > &s, size_t pos, size_t n, _CharT zero, _CharT one)
template<class _CharT, class _Traits, class _Alloc>
void M_copy_to_string (std::basic_string< _CharT, _Traits, _Alloc > &, _CharT, _CharT) const
template<class _CharT, class _Traits, class _Alloc>
void M_copy_from_string (const std::basic_string< _CharT, _Traits, _Alloc > &s, size_t pos, size_t n)
template<class _CharT, class _Traits, class _Alloc>
void M_copy_to_string (std::basic_string< _CharT, _Traits, _Alloc > &s) const
size_t count () const noexcept
 Returns the number of bits which are set.
constexpr size_t size () const noexcept
 Returns the total number of bits.
bool operator== (const bitset< Nb > &rhs) const noexcept
 These comparisons for equality/inequality are, well, bitwise.
bool operator!= (const bitset< Nb > &rhs) const noexcept
bool operator< (const bitset< Nb > &rhs) const noexcept
bool operator<= (const bitset< Nb > &rhs) const noexcept
bool operator> (const bitset< Nb > &rhs) const noexcept
bool operator>= (const bitset< Nb > &rhs) const noexcept
int getMSB () const noexcept
bool increment () noexcept
bool decrement () noexcept
template<size_t NbOpnd>
bool add (const bitset< NbOpnd > &a, const bitset< NbOpnd > &b) noexcept
template<size_t NbOpnd>
bool add (const bitset< NbOpnd > &a) noexcept
 Incremental add.
template<size_t NbOpnd>
bool sub (const bitset< NbOpnd > &a, const bitset< NbOpnd > &b) noexcept
template<size_t NbOpnd>
bool sub (const bitset< NbOpnd > &a) noexcept
bool test (size_t position) const
 Tests the value of a bit.
bool all () const noexcept
 Tests whether all the bits are on.
bool any () const noexcept
 Tests whether any of the bits are on.
bool none () const noexcept
 Tests whether any of the bits are on.
bitset< Nb > operator<< (size_t position) const noexcept
 Self-explanatory.
bitset< Nb > operator>> (size_t position) const noexcept
size_t _Find_first () const noexcept
 Finds the index of the first "on" bit.
size_t _Find_next (size_t prev) const noexcept
 Finds the index of the next "on" bit after prev.
Public Member Functions inherited from universal_bitset::BaseBitset< UBB_WORDS(Nb)>
constexpr BaseBitset () noexcept
constexpr BaseBitset (unsigned long long val) noexcept
constexpr bool M_testBit (size_t pos) const noexcept
WordT & M_getword (size_t pos) noexcept
constexpr WordT M_getword (size_t pos) const noexcept
const WordT * M_getdata () const noexcept
WordT & M_hiword () noexcept
constexpr WordT M_hiword () const noexcept
void M_do_and (const BaseBitset< Nw > &x) noexcept
void M_do_or (const BaseBitset< Nw > &x) noexcept
void M_do_xor (const BaseBitset< Nw > &x) noexcept
void M_do_left_shift (size_t shift) noexcept
void M_do_right_shift (size_t shift) noexcept
void M_do_flip () noexcept
void M_do_set () noexcept
void M_do_reset () noexcept
bool M_is_equal (const BaseBitset< Nw > &x) const noexcept
bool M_is_less_than (const BaseBitset< Nw > &x) const noexcept
 Blocked unsigned less-than operation.
bool M_is_greater_than (const BaseBitset< Nw > &x) const noexcept
 Blocked unsigned greater-than operation.
int M_getMSB () const noexcept
 Finds the position of the highest set bit.
bool M_increment () noexcept
 Increments underlying value by unity.
bool M_decrement () noexcept
 Decrements underlying value by unity.
bool M_do_add (const BaseBitset< UBB_WORDS(Nb)> &a, const BaseBitset< UBB_WORDS(Nb)> &b) noexcept
 Slotwise addtion to this value.
bool M_do_add (const BaseBitset< UBB_WORDS(Nb)> &a) noexcept
 Slotwise increment of this value.
bool M_do_sub (const BaseBitset< UBB_WORDS(Nb)> &a, const BaseBitset< UBB_WORDS(Nb)> &b) noexcept
 Slotwise subtraction into this value.
bool M_do_sub (const BaseBitset< UBB_WORDS(Nb)> &a) noexcept
 Slotwise decrement of this value.
bool M_are_all () const noexcept
bool M_is_any () const noexcept
size_t M_do_count () const noexcept
unsigned long M_do_to_ulong () const
unsigned long long M_do_to_ullong () const
size_t M_do_find_first (size_t) const noexcept
size_t M_do_find_next (size_t, size_t) const noexcept

Friends

struct std::hash< bitset >
class reference

Additional Inherited Members

Static Public Member Functions inherited from universal_bitset::BaseBitset< UBB_WORDS(Nb)>
static int S_getMSB (const WordT &val)
 Finds leading bit of value passed.
static bool S_increment (WordT &val)
 increments the value passed.
static bool S_decrement (WordT &val)
 decrements the value passed.
static bool S_add (WordT &accum, const WordT &a, const WordT &b, bool carry)
 Performs a two-operand addition on a single slot.
static bool S_add (WordT &accum, const WordT &a, bool carry)
 Performs a two-operand addition on a single slot.
static bool S_sub (WordT &accum, const WordT &a, const WordT &b, const bool borrow)
 Performs a two-operand subtraction on a single slot.
static bool S_sub (WordT &accum, const WordT &a, bool borrow)
 Performs a single-operand subtraction.
static constexpr size_t S_whichword (size_t pos) noexcept
static constexpr size_t S_whichbyte (size_t pos) noexcept
static constexpr size_t S_whichbit (size_t pos) noexcept
static constexpr WordT S_maskbit (size_t pos) noexcept
Public Attributes inherited from universal_bitset::BaseBitset< UBB_WORDS(Nb)>
WordT M_w [Nw]
 0 is the least significant word.

Detailed Description

template<size_t Nb>
class universal_bitset::bitset< Nb >

The bitset class represents a fixed-size sequence of bits.

(Note that bitset does not meet the formal requirements of a container. Mainly, it lacks iterators.)

The template argument, Nb, may be any non-negative number, specifying the number of bits (e.g., "0", "12", "1024*1024").

In the general unoptimized case, storage is allocated in word-sized blocks. Let B be the number of bits in a word, then (Nb+(B-1))/B words will be used for storage. B - NbB bits are unused. (They are the high-order bits in the highest word.) It is a class invariant that those unused bits are always zero.

If you think of bitset as a simple array of bits, be aware that your mental picture is reversed: a bitset behaves the same way as bits in integers do, with the bit at index 0 in the least significant / right-hand position, and the bit at index Nb-1 in the most significant / left-hand position. Thus, unlike other containers, a bitset's index counts from right to left, to put it very loosely.

This behavior is preserved when translating to and from strings. For example, the first line of the following program probably prints b('a') is 0001100001 on a modern ASCII system.

#include <bitset>
#include <iostream>
#include <sstream>
using namespace std;
int main()
{
long a = 'a';
bitset<10> b(a);
cout << "b('a') is " << b << endl;
ostringstream s;
s << b;
string str = s.str();
cout << "index 3 in the string is " << str[3] << " but\n"
<< "index 3 in the bitset is " << b[3] << endl;
}
constexpr bitset() noexcept
All bits set to zero.
Definition ubb.h:1504
STL namespace.

Also see: https://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_containers.html for a description of extensions.

Most of the actual code isn't contained in bitset<> itself, but in the base class BaseBitset. The base class works with whole words, not with individual bits. This allows us to specialize BaseBitset for the important special case where the bitset is only a single word.

Extra confusion can result due to the fact that the storage for BaseBitset is a regular array, and is indexed as such. This is carefully encapsulated.

Constructor & Destructor Documentation

◆ bitset() [1/6]

template<size_t Nb>
universal_bitset::bitset< Nb >::bitset ( )
inlineconstexprnoexcept

All bits set to zero.

◆ bitset() [2/6]

template<size_t Nb>
universal_bitset::bitset< Nb >::bitset ( unsigned long long val)
inlineconstexprnoexcept

Initial bits bitwise-copied from a single word (others set to zero).

◆ bitset() [3/6]

template<size_t Nb>
template<class _CharT, class _Traits, class _Alloc>
universal_bitset::bitset< Nb >::bitset ( const std::basic_string< _CharT, _Traits, _Alloc > & s,
size_t position = 0 )
inlineexplicit

Use a subset of a string.

Parameters
sA string of 0 and 1 characters.
positionIndex of the first character in s to use; defaults to zero.
Exceptions
std::out_of_rangeIf pos is bigger the size of s.
std::invalid_argumentIf a character appears in the string which is neither 0 nor 1.

◆ bitset() [4/6]

template<size_t Nb>
template<class _CharT, class _Traits, class _Alloc>
universal_bitset::bitset< Nb >::bitset ( const std::basic_string< _CharT, _Traits, _Alloc > & s,
size_t position,
size_t n )
inline

Use a subset of a string.

Parameters
sA string of 0 and 1 characters.
positionIndex of the first character in s to use.
nThe number of characters to copy.
Exceptions
std::out_of_rangeIf position is bigger the size of s.
std::invalid_argumentIf a character appears in the string which is neither 0 nor 1.

◆ bitset() [5/6]

template<size_t Nb>
template<class _CharT, class _Traits, class _Alloc>
universal_bitset::bitset< Nb >::bitset ( const std::basic_string< _CharT, _Traits, _Alloc > & s,
size_t position,
size_t n,
_CharT zero,
_CharT one = _CharT('1') )
inline

◆ bitset() [6/6]

template<size_t Nb>
template<typename _CharT>
universal_bitset::bitset< Nb >::bitset ( const _CharT * str,
typename std::basic_string< _CharT >::size_type n = std::basic_string<_CharT>::npos,
_CharT zero = _CharT('0'),
_CharT one = _CharT('1') )
inlineexplicit

Construct from a character array.

Parameters
strAn array of characters zero and one.
nThe number of characters to use.
zeroThe character corresponding to the value 0.
oneThe character corresponding to the value 1.
Exceptions
std::invalid_argumentIf a character appears in the string which is neither zero nor one.

Member Function Documentation

◆ _Find_first()

template<size_t Nb>
size_t universal_bitset::bitset< Nb >::_Find_first ( ) const
inlinenoexcept

Finds the index of the first "on" bit.

Returns
The index of the first bit set, or size() if not found.
See also
_Find_next

◆ _Find_next()

template<size_t Nb>
size_t universal_bitset::bitset< Nb >::_Find_next ( size_t prev) const
inlinenoexcept

Finds the index of the next "on" bit after prev.

Returns
The index of the next bit set, or size() if not found.
Parameters
prevWhere to start searching.
See also
_Find_first

◆ add() [1/2]

template<size_t Nb>
template<size_t NbOpnd>
bool universal_bitset::bitset< Nb >::add ( const bitset< NbOpnd > & a)
inlinenoexcept

Incremental add.

◆ add() [2/2]

template<size_t Nb>
template<size_t NbOpnd>
bool universal_bitset::bitset< Nb >::add ( const bitset< NbOpnd > & a,
const bitset< NbOpnd > & b )
inlinenoexcept

◆ all()

template<size_t Nb>
bool universal_bitset::bitset< Nb >::all ( ) const
inlinenoexcept

Tests whether all the bits are on.

Returns
True if all the bits are set.

◆ any()

template<size_t Nb>
bool universal_bitset::bitset< Nb >::any ( ) const
inlinenoexcept

Tests whether any of the bits are on.

Returns
True if at least one bit is set.

◆ count()

template<size_t Nb>
size_t universal_bitset::bitset< Nb >::count ( ) const
inlinenoexcept

Returns the number of bits which are set.

◆ decrement()

template<size_t Nb>
bool universal_bitset::bitset< Nb >::decrement ( )
inlinenoexcept

◆ flip() [1/2]

template<size_t Nb>
bitset< Nb > & universal_bitset::bitset< Nb >::flip ( )
inlinenoexcept

Toggles every bit to its opposite value.

◆ flip() [2/2]

template<size_t Nb>
bitset< Nb > & universal_bitset::bitset< Nb >::flip ( size_t position)
inline

Toggles a given bit to its opposite value.

Parameters
positionThe index of the bit.
Exceptions
std::out_of_rangeIf pos is bigger the size of the set.

◆ getMSB()

template<size_t Nb>
int universal_bitset::bitset< Nb >::getMSB ( ) const
inlinenoexcept

◆ increment()

template<size_t Nb>
bool universal_bitset::bitset< Nb >::increment ( )
inlinenoexcept

◆ M_copy_from_ptr()

template<size_t Nb>
template<class _CharT, class _Traits>
void universal_bitset::bitset< Nb >::M_copy_from_ptr ( const _CharT * s,
size_t len,
size_t pos,
size_t n,
_CharT zero,
_CharT one )

◆ M_copy_from_string() [1/2]

template<size_t Nb>
template<class _CharT, class _Traits, class _Alloc>
void universal_bitset::bitset< Nb >::M_copy_from_string ( const std::basic_string< _CharT, _Traits, _Alloc > & s,
size_t pos,
size_t n )
inline

◆ M_copy_from_string() [2/2]

template<size_t Nb>
template<class _CharT, class _Traits, class _Alloc>
void universal_bitset::bitset< Nb >::M_copy_from_string ( const std::basic_string< _CharT, _Traits, _Alloc > & s,
size_t pos,
size_t n,
_CharT zero,
_CharT one )
inline

◆ M_copy_to_string() [1/2]

template<size_t Nb>
template<class _CharT, class _Traits, class _Alloc>
void universal_bitset::bitset< Nb >::M_copy_to_string ( std::basic_string< _CharT, _Traits, _Alloc > & s,
_CharT zero,
_CharT one ) const

◆ M_copy_to_string() [2/2]

template<size_t Nb>
template<class _CharT, class _Traits, class _Alloc>
void universal_bitset::bitset< Nb >::M_copy_to_string ( std::basic_string< _CharT, _Traits, _Alloc > & s) const
inline

◆ none()

template<size_t Nb>
bool universal_bitset::bitset< Nb >::none ( ) const
inlinenoexcept

Tests whether any of the bits are on.

Returns
True if none of the bits are set.

◆ operator!=()

template<size_t Nb>
bool universal_bitset::bitset< Nb >::operator!= ( const bitset< Nb > & rhs) const
inlinenoexcept

◆ operator&=()

template<size_t Nb>
bitset< Nb > & universal_bitset::bitset< Nb >::operator&= ( const bitset< Nb > & rhs)
inlinenoexcept

Operations on bitsets.

Parameters
rhsA same-sized bitset.

These should be self-explanatory.

◆ operator<()

template<size_t Nb>
bool universal_bitset::bitset< Nb >::operator< ( const bitset< Nb > & rhs) const
inlinenoexcept

◆ operator<<()

template<size_t Nb>
bitset< Nb > universal_bitset::bitset< Nb >::operator<< ( size_t position) const
inlinenoexcept

Self-explanatory.

◆ operator<<=()

template<size_t Nb>
bitset< Nb > & universal_bitset::bitset< Nb >::operator<<= ( size_t position)
inlinenoexcept

Operations on bitsets.

Parameters
positionThe number of places to shift.

These should be self-explanatory.

◆ operator<=()

template<size_t Nb>
bool universal_bitset::bitset< Nb >::operator<= ( const bitset< Nb > & rhs) const
inlinenoexcept

◆ operator==()

template<size_t Nb>
bool universal_bitset::bitset< Nb >::operator== ( const bitset< Nb > & rhs) const
inlinenoexcept

These comparisons for equality/inequality are, well, bitwise.

◆ operator>()

template<size_t Nb>
bool universal_bitset::bitset< Nb >::operator> ( const bitset< Nb > & rhs) const
inlinenoexcept

◆ operator>=()

template<size_t Nb>
bool universal_bitset::bitset< Nb >::operator>= ( const bitset< Nb > & rhs) const
inlinenoexcept

◆ operator>>()

template<size_t Nb>
bitset< Nb > universal_bitset::bitset< Nb >::operator>> ( size_t position) const
inlinenoexcept

◆ operator>>=()

template<size_t Nb>
bitset< Nb > & universal_bitset::bitset< Nb >::operator>>= ( size_t position)
inlinenoexcept

◆ operator[]() [1/2]

template<size_t Nb>
reference universal_bitset::bitset< Nb >::operator[] ( size_t position)
inline

Array-indexing support.

Parameters
positionIndex into the bitset.
Returns
A bool for a const bitset. For non-const bitsets, an instance of the reference proxy class.
Note
These operators do no range checking and throw no exceptions, as required by DR 11 to the standard.

_GLIBCXX_RESOLVE_LIB_DEFECTS Note that this implementation already resolves DR 11 (items 1 and 2), but does not do the range-checking required by that DR's resolution. -pme The DR has since been changed: range-checking is a precondition (users' responsibility), and these functions must not throw. -pme

◆ operator[]() [2/2]

template<size_t Nb>
bool universal_bitset::bitset< Nb >::operator[] ( size_t position) const
inlineconstexpr

◆ operator^=()

template<size_t Nb>
bitset< Nb > & universal_bitset::bitset< Nb >::operator^= ( const bitset< Nb > & rhs)
inlinenoexcept

◆ operator|=()

template<size_t Nb>
bitset< Nb > & universal_bitset::bitset< Nb >::operator|= ( const bitset< Nb > & rhs)
inlinenoexcept

◆ operator~()

template<size_t Nb>
bitset< Nb > universal_bitset::bitset< Nb >::operator~ ( ) const
inlinenoexcept

See the no-argument flip().

◆ reset() [1/2]

template<size_t Nb>
bitset< Nb > & universal_bitset::bitset< Nb >::reset ( )
inlinenoexcept

Sets every bit to false.

◆ reset() [2/2]

template<size_t Nb>
bitset< Nb > & universal_bitset::bitset< Nb >::reset ( size_t position)
inline

Sets a given bit to false.

Parameters
positionThe index of the bit.
Exceptions
std::out_of_rangeIf pos is bigger the size of the set.

Same as writing set(pos,false).

◆ set() [1/2]

template<size_t Nb>
bitset< Nb > & universal_bitset::bitset< Nb >::set ( )
inlinenoexcept

Sets every bit to true.

◆ set() [2/2]

template<size_t Nb>
bitset< Nb > & universal_bitset::bitset< Nb >::set ( size_t position,
bool val = true )
inline

Sets a given bit to a particular value.

Parameters
positionThe index of the bit.
valEither true or false, defaults to true.
Exceptions
std::out_of_rangeIf pos is bigger the size of the set.

◆ size()

template<size_t Nb>
size_t universal_bitset::bitset< Nb >::size ( ) const
inlineconstexprnoexcept

Returns the total number of bits.

◆ sub() [1/2]

template<size_t Nb>
template<size_t NbOpnd>
bool universal_bitset::bitset< Nb >::sub ( const bitset< NbOpnd > & a)
inlinenoexcept

◆ sub() [2/2]

template<size_t Nb>
template<size_t NbOpnd>
bool universal_bitset::bitset< Nb >::sub ( const bitset< NbOpnd > & a,
const bitset< NbOpnd > & b )
inlinenoexcept

◆ test()

template<size_t Nb>
bool universal_bitset::bitset< Nb >::test ( size_t position) const
inline

Tests the value of a bit.

Parameters
positionThe index of a bit.
Returns
The value at pos.
Exceptions
std::out_of_rangeIf pos is bigger the size of the set.

◆ to_string() [1/8]

template<size_t Nb>
std::basic_string< char, std::char_traits< char >, std::allocator< char > > universal_bitset::bitset< Nb >::to_string ( ) const
inline

◆ to_string() [2/8]

template<size_t Nb>
template<class _CharT>
std::basic_string< _CharT, std::char_traits< _CharT >, std::allocator< _CharT > > universal_bitset::bitset< Nb >::to_string ( ) const
inline

◆ to_string() [3/8]

template<size_t Nb>
template<class _CharT, class _Traits>
std::basic_string< _CharT, _Traits, std::allocator< _CharT > > universal_bitset::bitset< Nb >::to_string ( ) const
inline

◆ to_string() [4/8]

template<size_t Nb>
template<class _CharT, class _Traits, class _Alloc>
std::basic_string< _CharT, _Traits, _Alloc > universal_bitset::bitset< Nb >::to_string ( ) const
inline

Returns a character interpretation of the bitset.

Returns
The string equivalent of the bits.

Note the ordering of the bits: decreasing character positions correspond to increasing bit positions (see the main class notes for an example).

◆ to_string() [5/8]

template<size_t Nb>
template<class _CharT>
std::basic_string< _CharT, std::char_traits< _CharT >, std::allocator< _CharT > > universal_bitset::bitset< Nb >::to_string ( _CharT zero,
_CharT one = _CharT('1') ) const
inline

◆ to_string() [6/8]

template<size_t Nb>
template<class _CharT, class _Traits>
std::basic_string< _CharT, _Traits, std::allocator< _CharT > > universal_bitset::bitset< Nb >::to_string ( _CharT zero,
_CharT one = _CharT('1') ) const
inline

◆ to_string() [7/8]

template<size_t Nb>
template<class _CharT, class _Traits, class _Alloc>
std::basic_string< _CharT, _Traits, _Alloc > universal_bitset::bitset< Nb >::to_string ( _CharT zero,
_CharT one = _CharT('1') ) const
inline

◆ to_string() [8/8]

template<size_t Nb>
std::basic_string< char, std::char_traits< char >, std::allocator< char > > universal_bitset::bitset< Nb >::to_string ( char zero,
char one = '1' ) const
inline

◆ to_ullong()

template<size_t Nb>
unsigned long long universal_bitset::bitset< Nb >::to_ullong ( ) const
inline

◆ to_ulong()

template<size_t Nb>
unsigned long universal_bitset::bitset< Nb >::to_ulong ( ) const
inline

Returns a numerical interpretation of the bitset.

Returns
The integral equivalent of the bits.
Exceptions
std::overflow_errorIf there are too many bits to be represented in an unsigned long.

◆ Unchecked_flip()

template<size_t Nb>
bitset< Nb > & universal_bitset::bitset< Nb >::Unchecked_flip ( size_t pos)
inlinenoexcept

◆ Unchecked_reset()

template<size_t Nb>
bitset< Nb > & universal_bitset::bitset< Nb >::Unchecked_reset ( size_t pos)
inlinenoexcept

◆ Unchecked_set() [1/2]

template<size_t Nb>
bitset< Nb > & universal_bitset::bitset< Nb >::Unchecked_set ( size_t pos)
inlinenoexcept

These versions of single-bit set, reset, flip, and test are extensions from the SGI version.

They do no range checking.

◆ Unchecked_set() [2/2]

template<size_t Nb>
bitset< Nb > & universal_bitset::bitset< Nb >::Unchecked_set ( size_t pos,
int val )
inlinenoexcept

◆ Unchecked_test()

template<size_t Nb>
bool universal_bitset::bitset< Nb >::Unchecked_test ( size_t pos) const
inlineconstexprnoexcept

◆ reference

template<size_t Nb>
friend class reference
friend

◆ std::hash< bitset >

template<size_t Nb>
friend struct std::hash< bitset >
friend

The documentation for this class was generated from the following file:
  • /home/runner/work/universal/universal/include/sw/universal/internal/bitblock/ubb.h