KTL
Loading...
Searching...
No Matches
ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment > Class Template Reference

A packed pointer-like type which takes advantage of any bits that don't get used due to alignment. More...

#include <packed_ptr.h>

Public Types

using ptr_type = PtrT
 
using int_type = detail::underlying_type_t< IntT >
 

Public Member Functions

 packed_ptr () noexcept
 
 packed_ptr (PtrT p, IntT value) noexcept
 
 packed_ptr (PtrT p) noexcept
 
 packed_ptr (IntT value) noexcept
 
packed_ptroperator= (PtrT p) noexcept
 
packed_ptroperator= (IntT value) noexcept
 
template<typename Y = IntT, typename = std::enable_if_t<!std::is_same_v<Y, bool>, Y>>
 operator ptr_type () const noexcept
 
template<typename Y = IntT, typename = std::enable_if_t<!std::is_same_v<Y, bool>, Y>>
 operator IntT () const noexcept
 
 operator bool () const noexcept
 
ptr_type operator-> () const noexcept
 
template<typename... Ts>
decltype(auto) operator() (Ts &&... args) const noexcept
 
ptr_type get_ptr () const noexcept
 
IntT get_int () const noexcept
 
void set_ptr (PtrT p) noexcept
 
void set_int (IntT value) noexcept
 

Public Attributes

decltype(*std::declval< PtrT >() operator* )() const noexcept
 

Static Public Attributes

static constexpr uintmax_t UsedBits = detail::bits_in_range(static_cast<int64_t>(Min), static_cast<int64_t>(Max))
 
static constexpr uintmax_t FreeBits = detail::log2(Alignment)
 

Friends

bool operator== (packed_ptr pack, PtrT p) noexcept
 
bool operator== (packed_ptr pack, IntT n) noexcept
 
bool operator== (PtrT p, packed_ptr pack) noexcept
 
bool operator== (IntT n, packed_ptr pack) noexcept
 

Detailed Description

template<typename PtrT, typename IntT, IntT Min, IntT Max, size_t Alignment>
class ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >

A packed pointer-like type which takes advantage of any bits that don't get used due to alignment.

Template Parameters
PtrTThe pointer type to use
IntTThe integer type to use

Member Typedef Documentation

◆ int_type

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
using ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::int_type = detail::underlying_type_t<IntT>

◆ ptr_type

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
using ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::ptr_type = PtrT

Constructor & Destructor Documentation

◆ packed_ptr() [1/4]

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::packed_ptr ( )
inlinenoexcept

◆ packed_ptr() [2/4]

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::packed_ptr ( PtrT  p,
IntT  value 
)
inlinenoexcept

◆ packed_ptr() [3/4]

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::packed_ptr ( PtrT  p)
inlinenoexcept

◆ packed_ptr() [4/4]

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::packed_ptr ( IntT  value)
inlinenoexcept

Member Function Documentation

◆ get_int()

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
IntT ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::get_int ( ) const
inlinenoexcept

◆ get_ptr()

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
ptr_type ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::get_ptr ( ) const
inlinenoexcept

◆ operator bool()

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::operator bool ( ) const
inlineexplicitnoexcept

◆ operator IntT()

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
template<typename Y = IntT, typename = std::enable_if_t<!std::is_same_v<Y, bool>, Y>>
ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::operator IntT ( ) const
inlinenoexcept

◆ operator ptr_type()

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
template<typename Y = IntT, typename = std::enable_if_t<!std::is_same_v<Y, bool>, Y>>
ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::operator ptr_type ( ) const
inlinenoexcept

◆ operator()()

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
template<typename... Ts>
decltype(auto) ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::operator() ( Ts &&...  args) const
inlinenoexcept

◆ operator->()

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
ptr_type ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::operator-> ( ) const
inlinenoexcept

◆ operator=() [1/2]

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
packed_ptr & ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::operator= ( IntT  value)
inlinenoexcept

◆ operator=() [2/2]

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
packed_ptr & ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::operator= ( PtrT  p)
inlinenoexcept

◆ set_int()

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
void ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::set_int ( IntT  value)
inlinenoexcept

◆ set_ptr()

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
void ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::set_ptr ( PtrT  p)
inlinenoexcept

Friends And Related Symbol Documentation

◆ operator== [1/4]

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
bool operator== ( IntT  n,
packed_ptr< PtrT, IntT, Min, Max, Alignment >  pack 
)
friend

◆ operator== [2/4]

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
bool operator== ( packed_ptr< PtrT, IntT, Min, Max, Alignment >  pack,
IntT  n 
)
friend

◆ operator== [3/4]

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
bool operator== ( packed_ptr< PtrT, IntT, Min, Max, Alignment >  pack,
PtrT  p 
)
friend

◆ operator== [4/4]

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
bool operator== ( PtrT  p,
packed_ptr< PtrT, IntT, Min, Max, Alignment >  pack 
)
friend

Member Data Documentation

◆ FreeBits

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
constexpr uintmax_t ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::FreeBits = detail::log2(Alignment)
staticconstexpr

◆ operator*

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
decltype(*std::declval< PtrT >() ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::operator*) () const noexcept
inlinenoexcept

◆ UsedBits

template<typename PtrT , typename IntT , IntT Min, IntT Max, size_t Alignment>
constexpr uintmax_t ktl::packed_ptr< PtrT, IntT, Min, Max, Alignment >::UsedBits = detail::bits_in_range(static_cast<int64_t>(Min), static_cast<int64_t>(Max))
staticconstexpr

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