KTL
Loading...
Searching...
No Matches
ktl::debug< Alloc, Container > Class Template Reference

#include <debug.h>

Public Types

typedef detail::get_size_type_t< Alloc > size_type
 

Public Member Functions

 debug (Container &container) noexcept(std::is_nothrow_default_constructible_v< Alloc >)
 Construct the allocator with a reference to a container object.
 
template<typename... Args, typename = std::enable_if_t< std::is_constructible_v<Alloc, Args...>>>
 debug (Container &container, Args &&... args) noexcept(std::is_nothrow_constructible_v< Alloc, Args... >)
 Constructor for forwarding any arguments to the underlying allocator.
 
 debug (const debug &)=default
 
 debug (debug &&)=default
 
debugoperator= (const debug &)=default
 
debugoperator= (debug &&)=default
 
bool operator== (const debug &rhs) const noexcept(detail::has_nothrow_equal_v< Alloc >)
 
bool operator!= (const debug &rhs) const noexcept(detail::has_nothrow_not_equal_v< Alloc >)
 
void * allocate (size_type n, const source_location &source=KTL_SOURCE()) noexcept(detail::has_nothrow_allocate_v< Alloc >)
 Attempts to allocate a chunk of memory defined by n.
 
void deallocate (void *p, size_type n) noexcept(detail::has_nothrow_deallocate_v< Alloc >)
 Attempts to deallocate the memory at location p.
 
template<typename T , typename... Args>
std::enable_if< detail::has_construct_v< Alloc, T *, Args... >, void >::type construct (T *p, Args &&... args) noexcept(detail::has_nothrow_construct_v< Alloc, T *, Args... >)
 Constructs an object of T with the given ...args at the given location.
 
template<typename T >
std::enable_if< detail::has_destroy_v< Alloc, T * >, void >::type destroy (T *p) noexcept(detail::has_nothrow_destroy_v< Alloc, T * >)
 Destructs an object of T at the given location.
 
template<typename A = Alloc>
std::enable_if< detail::has_max_size_v< A >, size_type >::type max_size () const noexcept(detail::has_nothrow_max_size_v< A >)
 Returns the maximum size that an allocation can be.
 
template<typename A = Alloc>
std::enable_if< detail::has_owns_v< A >, bool >::type owns (void *p) const noexcept(detail::has_nothrow_owns_v< A >)
 Returns whether or not the allocator owns the given location in memory.
 
Alloc & get_allocator () noexcept
 Returns a reference to the underlying allocator.
 
const Alloc & get_allocator () const noexcept
 Returns a const reference to the underlying allocator.
 
Container & get_container () noexcept
 Return a reference to the container that will be used to accumulate statistics.
 
const Container & get_container () const noexcept
 Return a const reference to the container that will be used to accumulate statistics.
 

Member Typedef Documentation

◆ size_type

template<typename Alloc , typename Container >
typedef detail::get_size_type_t<Alloc> ktl::debug< Alloc, Container >::size_type

Constructor & Destructor Documentation

◆ debug() [1/4]

template<typename Alloc , typename Container >
ktl::debug< Alloc, Container >::debug ( Container &  container)
inlineexplicitnoexcept

Construct the allocator with a reference to a container object.

Parameters
containerThe container to use for populating statistics

◆ debug() [2/4]

template<typename Alloc , typename Container >
template<typename... Args, typename = std::enable_if_t< std::is_constructible_v<Alloc, Args...>>>
ktl::debug< Alloc, Container >::debug ( Container &  container,
Args &&...  args 
)
inlineexplicitnoexcept

Constructor for forwarding any arguments to the underlying allocator.

◆ debug() [3/4]

template<typename Alloc , typename Container >
ktl::debug< Alloc, Container >::debug ( const debug< Alloc, Container > &  )
default

◆ debug() [4/4]

template<typename Alloc , typename Container >
ktl::debug< Alloc, Container >::debug ( debug< Alloc, Container > &&  )
default

Member Function Documentation

◆ allocate()

template<typename Alloc , typename Container >
void * ktl::debug< Alloc, Container >::allocate ( size_type  n,
const source_location source = KTL_SOURCE() 
)
inlinenoexcept

Attempts to allocate a chunk of memory defined by n.

Parameters
nThe amount of bytes to allocate memory for
Returns
A location in memory that is at least n bytes big or nullptr if it could not be allocated

◆ construct()

template<typename Alloc , typename Container >
template<typename T , typename... Args>
std::enable_if< detail::has_construct_v< Alloc, T *, Args... >, void >::type ktl::debug< Alloc, Container >::construct ( T *  p,
Args &&...  args 
)
inlinenoexcept

Constructs an object of T with the given ...args at the given location.

Note
Only defined if the underlying allocator defines it
Template Parameters
...ArgsThe types of the arguments
Parameters
pThe location of the object in memory
...argsA range of arguments to use to construct the object

◆ deallocate()

template<typename Alloc , typename Container >
void ktl::debug< Alloc, Container >::deallocate ( void *  p,
size_type  n 
)
inlinenoexcept

Attempts to deallocate the memory at location p.

Parameters
pThe location in memory to deallocate
nThe size that was initially allocated

◆ destroy()

template<typename Alloc , typename Container >
template<typename T >
std::enable_if< detail::has_destroy_v< Alloc, T * >, void >::type ktl::debug< Alloc, Container >::destroy ( T *  p)
inlinenoexcept

Destructs an object of T at the given location.

Note
Only defined if the underlying allocator defines it
Parameters
pThe location of the object in memory

◆ get_allocator() [1/2]

template<typename Alloc , typename Container >
const Alloc & ktl::debug< Alloc, Container >::get_allocator ( ) const
inlinenoexcept

Returns a const reference to the underlying allocator.

Returns
The allocator

◆ get_allocator() [2/2]

template<typename Alloc , typename Container >
Alloc & ktl::debug< Alloc, Container >::get_allocator ( )
inlinenoexcept

Returns a reference to the underlying allocator.

Returns
The allocator

◆ get_container() [1/2]

template<typename Alloc , typename Container >
const Container & ktl::debug< Alloc, Container >::get_container ( ) const
inlinenoexcept

Return a const reference to the container that will be used to accumulate statistics.

Returns
The stream

◆ get_container() [2/2]

template<typename Alloc , typename Container >
Container & ktl::debug< Alloc, Container >::get_container ( )
inlinenoexcept

Return a reference to the container that will be used to accumulate statistics.

Returns
The stream

◆ max_size()

template<typename Alloc , typename Container >
template<typename A = Alloc>
std::enable_if< detail::has_max_size_v< A >, size_type >::type ktl::debug< Alloc, Container >::max_size ( ) const
inlinenoexcept

Returns the maximum size that an allocation can be.

Note
Only defined if the underlying allocator defines it
Returns
The maximum size an allocation may be

◆ operator!=()

template<typename Alloc , typename Container >
bool ktl::debug< Alloc, Container >::operator!= ( const debug< Alloc, Container > &  rhs) const
inlinenoexcept

◆ operator=() [1/2]

template<typename Alloc , typename Container >
debug & ktl::debug< Alloc, Container >::operator= ( const debug< Alloc, Container > &  )
default

◆ operator=() [2/2]

template<typename Alloc , typename Container >
debug & ktl::debug< Alloc, Container >::operator= ( debug< Alloc, Container > &&  )
default

◆ operator==()

template<typename Alloc , typename Container >
bool ktl::debug< Alloc, Container >::operator== ( const debug< Alloc, Container > &  rhs) const
inlinenoexcept

◆ owns()

template<typename Alloc , typename Container >
template<typename A = Alloc>
std::enable_if< detail::has_owns_v< A >, bool >::type ktl::debug< Alloc, Container >::owns ( void *  p) const
inlinenoexcept

Returns whether or not the allocator owns the given location in memory.

Note
Only defined if the underlying allocator defines it
Parameters
pThe location of the object in memory
Returns
Whether the allocator owns p

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