C++ Library Extensions 2022.12.09
To help learn modern C++ programming
tpf::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<typename T , typename = enable_if_integral<T>>
int count_set_bits (T bits)
 
template<typename T , typename = enable_if_integral<T>>
std::string to_bits (T bits)
 
template<typename T , typename = enable_if_integral<T>>
std::string to_hex (T v)
 
template<typename T , std::size_t N>
std::string to_hex_reverse (T(&v)[N])
 
template<typename T , std::size_t N>
std::string to_hex (T(&v)[N])
 
template<typename T , typename = enable_if_integral<T>>
std::string to_dec (T v)
 
template<typename T , std::size_t N>
std::string to_dec_reverse (T(&v)[N])
 
template<typename T , std::size_t N>
std::string to_dec (T(&v)[N])
 
template<typename T , typename = enable_if_integral<T>>
int field_with (T v)
 
template<typename T , typename = enable_if_integral<T>>
int numeric_width ()
 
template<typename T , typename = enable_if_integral<T>>
std::string to_dec_width (T v)
 
template<typename T , typename = enable_if_integral<T>>
std::string numeric_base (T v)
 
template<typename T , typename = enable_if_integral<T>>
std::string numeric_type_info ()
 
template<typename = void>
std::string integral_type_info ()
 
template<typename T , typename = enable_if_integral<T>>
std::string twos_complement (T c)
 

Variables

template<typename T >
constexpr bool is_char_v = hidden::st_is_character<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 tpf::bitwise::common_t = typedef std::common_type_t<S, T>

Definition at line 75 of file tpf_bitwise.hpp.

◆ enable_if_integral

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

Definition at line 66 of file tpf_bitwise.hpp.

◆ signed_common_t

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

Definition at line 80 of file tpf_bitwise.hpp.

◆ signed_t

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

Definition at line 72 of file tpf_bitwise.hpp.

◆ unsigned_common_t

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

Definition at line 85 of file tpf_bitwise.hpp.

◆ unsigned_t

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

Definition at line 69 of file tpf_bitwise.hpp.

Function Documentation

◆ count_set_bits()

template<typename T , typename = enable_if_integral<T>>
int tpf::bitwise::count_set_bits ( bits)

Definition at line 95 of file tpf_bitwise.hpp.

◆ field_with()

template<typename T , typename = enable_if_integral<T>>
int tpf::bitwise::field_with ( v)

Definition at line 244 of file tpf_bitwise.hpp.

Here is the caller graph for this function:

◆ integral_type_info()

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

Definition at line 307 of file tpf_bitwise.hpp.

◆ numeric_base()

template<typename T , typename = enable_if_integral<T>>
std::string tpf::bitwise::numeric_base ( v)

Definition at line 281 of file tpf_bitwise.hpp.

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

◆ numeric_type_info()

template<typename T , typename = enable_if_integral<T>>
std::string tpf::bitwise::numeric_type_info ( )

Definition at line 291 of file tpf_bitwise.hpp.

Here is the call graph for this function:

◆ numeric_width()

template<typename T , typename = enable_if_integral<T>>
int tpf::bitwise::numeric_width ( )

Definition at line 257 of file tpf_bitwise.hpp.

Here is the call graph for this function:

◆ to_bits()

template<typename T , typename = enable_if_integral<T>>
std::string tpf::bitwise::to_bits ( bits)

Definition at line 108 of file tpf_bitwise.hpp.

◆ to_dec() [1/2]

template<typename T , typename = enable_if_integral<T>>
std::string tpf::bitwise::to_dec ( v)

Definition at line 201 of file tpf_bitwise.hpp.

Here is the caller graph for this function:

◆ to_dec() [2/2]

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

Definition at line 229 of file tpf_bitwise.hpp.

Here is the call graph for this function:

◆ to_dec_reverse()

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

Definition at line 214 of file tpf_bitwise.hpp.

Here is the call graph for this function:

◆ to_dec_width()

template<typename T , typename = enable_if_integral<T>>
std::string tpf::bitwise::to_dec_width ( v)

Definition at line 266 of file tpf_bitwise.hpp.

Here is the caller graph for this function:

◆ to_hex() [1/2]

template<typename T , typename = enable_if_integral<T>>
std::string tpf::bitwise::to_hex ( v)

Definition at line 126 of file tpf_bitwise.hpp.

Here is the caller graph for this function:

◆ to_hex() [2/2]

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

Definition at line 186 of file tpf_bitwise.hpp.

Here is the call graph for this function:

◆ to_hex_reverse()

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

Definition at line 171 of file tpf_bitwise.hpp.

Here is the call graph for this function:

◆ twos_complement()

template<typename T , typename = enable_if_integral<T>>
std::string tpf::bitwise::twos_complement ( c)

Definition at line 326 of file tpf_bitwise.hpp.

Here is the call graph for this function:

Variable Documentation

◆ high_bit_mask

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

Definition at line 91 of file tpf_bitwise.hpp.

◆ is_char_v

template<typename T >
constexpr bool tpf::bitwise::is_char_v = hidden::st_is_character<T>::value
constexpr

Definition at line 53 of file tpf_bitwise.hpp.

◆ limits_max

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

Definition at line 55 of file tpf_bitwise.hpp.

◆ limits_min

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

Definition at line 56 of file tpf_bitwise.hpp.

◆ sizeof_bits

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

Definition at line 88 of file tpf_bitwise.hpp.