C++ Library Extensions 2022.12.09
To help learn modern C++ programming
cpg::bitwise Namespace Reference

Namespaces

namespace  hidden
 

Classes

struct  bit_pattern
 

Typedefs

template<typename T >
using enable_if_integral = std::enable_if_t< std::is_integral< T >::value >
 
template<typename T , typename = enable_if_integral<T>>
using unsigned_t = std::make_unsigned_t< T >
 
template<typename T , typename = enable_if_integral<T>>
using signed_t = std::make_signed_t< T >
 
template<typename S , typename T >
using common_t = std::common_type_t< S, T >
 
template<typename S , typename T , typename = enable_if_integral<S>, typename = enable_if_integral<T>>
using signed_common_t = signed_t< common_t< S, T > >
 
template<typename S , typename T , typename = enable_if_integral<S>, typename = enable_if_integral<T>>
using unsigned_common_t = unsigned_t< common_t< S, T > >
 

Functions

template<std::integral T>
int count_set_bits (T bits)
 
template<std::integral T>
std::string to_bits (T bits)
 
template<std::integral T, std::size_t N>
std::string to_bits_reverse (T(&bits)[N])
 
template<std::integral T, std::size_t N>
std::string to_bits (T(&bits)[N])
 
template<std::integral T>
std::string to_hex (T v)
 
template<std::integral T, std::size_t N>
std::string to_hex_reverse (T(&v)[N])
 
template<std::integral T, std::size_t N>
std::string to_hex (T(&v)[N])
 
template<std::integral T>
std::string to_dec (T v)
 
template<std::integral T, std::size_t N>
std::string to_dec_reverse (T(&v)[N])
 
template<std::integral T, std::size_t N>
std::string to_dec (T(&v)[N])
 
template<std::integral T>
int field_with (T v)
 
template<std::integral T>
int numeric_width ()
 
template<std::integral T>
std::string to_dec_width (T v)
 
template<std::integral T>
std::string numeric_base (T v)
 
template<std::integral T>
std::string numeric_type_info ()
 
template<typename = void>
std::string integral_type_info ()
 
template<std::integral T>
std::string twos_complement (T c)
 

Variables

template<typename T >
constexpr bool is_char_v = hidden::st_is_character<std::remove_cvref_t<T>>::value
 
template<typename T >
constexpr T limits_max = std::numeric_limits<T>::max()
 
template<typename T >
constexpr T limits_min = std::numeric_limits<T>::min()
 
template<typename T >
constexpr int sizeof_bits = sizeof(T) * 8
 
template<typename T >
constexpr unsigned_t< T > high_bit_mask = unsigned_t<T>(1) << (sizeof_bits<T>-1)
 

Typedef Documentation

◆ common_t

template<typename S , typename T >
using cpg::bitwise::common_t = typedef std::common_type_t<S, T>

Definition at line 79 of file cpg_bitwise.hpp.

◆ enable_if_integral

template<typename T >
using cpg::bitwise::enable_if_integral = typedef std::enable_if_t<std::is_integral<T>::value>

Definition at line 70 of file cpg_bitwise.hpp.

◆ signed_common_t

template<typename S , typename T , typename = enable_if_integral<S>, typename = enable_if_integral<T>>
using cpg::bitwise::signed_common_t = typedef signed_t<common_t<S, T> >

Definition at line 84 of file cpg_bitwise.hpp.

◆ signed_t

template<typename T , typename = enable_if_integral<T>>
using cpg::bitwise::signed_t = typedef std::make_signed_t<T>

Definition at line 76 of file cpg_bitwise.hpp.

◆ unsigned_common_t

template<typename S , typename T , typename = enable_if_integral<S>, typename = enable_if_integral<T>>
using cpg::bitwise::unsigned_common_t = typedef unsigned_t<common_t<S, T> >

Definition at line 89 of file cpg_bitwise.hpp.

◆ unsigned_t

template<typename T , typename = enable_if_integral<T>>
using cpg::bitwise::unsigned_t = typedef std::make_unsigned_t<T>

Definition at line 73 of file cpg_bitwise.hpp.

Function Documentation

◆ count_set_bits()

template<std::integral T>
int cpg::bitwise::count_set_bits ( bits)

Definition at line 99 of file cpg_bitwise.hpp.

◆ field_with()

template<std::integral T>
int cpg::bitwise::field_with ( v)

Definition at line 279 of file cpg_bitwise.hpp.

Here is the caller graph for this function:

◆ integral_type_info()

template<typename = void>
std::string cpg::bitwise::integral_type_info ( )

Definition at line 342 of file cpg_bitwise.hpp.

Here is the caller graph for this function:

◆ numeric_base()

template<std::integral T>
std::string cpg::bitwise::numeric_base ( v)

Definition at line 316 of file cpg_bitwise.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ numeric_type_info()

template<std::integral T>
std::string cpg::bitwise::numeric_type_info ( )

Definition at line 326 of file cpg_bitwise.hpp.

Here is the call graph for this function:

◆ numeric_width()

template<std::integral T>
int cpg::bitwise::numeric_width ( )

Definition at line 292 of file cpg_bitwise.hpp.

Here is the call graph for this function:

◆ to_bits() [1/2]

template<std::integral T>
std::string cpg::bitwise::to_bits ( bits)

Definition at line 112 of file cpg_bitwise.hpp.

Here is the caller graph for this function:

◆ to_bits() [2/2]

template<std::integral T, std::size_t N>
std::string cpg::bitwise::to_bits ( T(&)  bits[N])

Definition at line 146 of file cpg_bitwise.hpp.

Here is the call graph for this function:

◆ to_bits_reverse()

template<std::integral T, std::size_t N>
std::string cpg::bitwise::to_bits_reverse ( T(&)  bits[N])

Definition at line 131 of file cpg_bitwise.hpp.

Here is the call graph for this function:

◆ to_dec() [1/2]

template<std::integral T>
std::string cpg::bitwise::to_dec ( v)

Definition at line 236 of file cpg_bitwise.hpp.

Here is the caller graph for this function:

◆ to_dec() [2/2]

template<std::integral T, std::size_t N>
std::string cpg::bitwise::to_dec ( T(&)  v[N])

Definition at line 264 of file cpg_bitwise.hpp.

Here is the call graph for this function:

◆ to_dec_reverse()

template<std::integral T, std::size_t N>
std::string cpg::bitwise::to_dec_reverse ( T(&)  v[N])

Definition at line 249 of file cpg_bitwise.hpp.

Here is the call graph for this function:

◆ to_dec_width()

template<std::integral T>
std::string cpg::bitwise::to_dec_width ( v)

Definition at line 301 of file cpg_bitwise.hpp.

Here is the caller graph for this function:

◆ to_hex() [1/2]

template<std::integral T>
std::string cpg::bitwise::to_hex ( v)

Definition at line 161 of file cpg_bitwise.hpp.

Here is the caller graph for this function:

◆ to_hex() [2/2]

template<std::integral T, std::size_t N>
std::string cpg::bitwise::to_hex ( T(&)  v[N])

Definition at line 221 of file cpg_bitwise.hpp.

Here is the call graph for this function:

◆ to_hex_reverse()

template<std::integral T, std::size_t N>
std::string cpg::bitwise::to_hex_reverse ( T(&)  v[N])

Definition at line 206 of file cpg_bitwise.hpp.

Here is the call graph for this function:

◆ twos_complement()

template<std::integral T>
std::string cpg::bitwise::twos_complement ( c)

Definition at line 361 of file cpg_bitwise.hpp.

Here is the call graph for this function:

Variable Documentation

◆ high_bit_mask

template<typename T >
constexpr unsigned_t<T> cpg::bitwise::high_bit_mask = unsigned_t<T>(1) << (sizeof_bits<T>-1)
constexpr

Definition at line 95 of file cpg_bitwise.hpp.

◆ is_char_v

template<typename T >
constexpr bool cpg::bitwise::is_char_v = hidden::st_is_character<std::remove_cvref_t<T>>::value
constexpr

Definition at line 57 of file cpg_bitwise.hpp.

◆ limits_max

template<typename T >
constexpr T cpg::bitwise::limits_max = std::numeric_limits<T>::max()
constexpr

Definition at line 59 of file cpg_bitwise.hpp.

◆ limits_min

template<typename T >
constexpr T cpg::bitwise::limits_min = std::numeric_limits<T>::min()
constexpr

Definition at line 60 of file cpg_bitwise.hpp.

◆ sizeof_bits

template<typename T >
constexpr int cpg::bitwise::sizeof_bits = sizeof(T) * 8
constexpr

Definition at line 92 of file cpg_bitwise.hpp.