KTL
ktl::overflow< Alloc, Stream > Class Template Reference

#include <overflow.h>

Public Types

typedef detail::get_size_type_t< Alloc > size_type
 

Public Member Functions

 overflow (Stream &stream) noexcept(std::is_nothrow_default_constructible_v< Alloc >)
 Construct the allocator with a reference to a stream object. More...
 
template<typename... Args, typename = std::enable_if_t< std::is_constructible_v<Alloc, Args...>>>
 overflow (Stream &stream, Args &&... args) noexcept(std::is_nothrow_constructible_v< Alloc, Args... >)
 Constructor for forwarding any arguments to the underlying allocator. More...
 
 overflow (const overflow &)=default
 
 overflow (overflow &&)=default
 
 ~overflow ()
 
overflowoperator= (const overflow &)=default
 
overflowoperator= (overflow &&)=default
 
bool operator== (const overflow &rhs) const noexcept(detail::has_nothrow_equal_v< Alloc >)
 
bool operator!= (const overflow &rhs) const noexcept(detail::has_nothrow_not_equal_v< Alloc >)
 
void * allocate (size_type n) noexcept(detail::has_nothrow_allocate_v< Alloc >)
 Attempts to allocate a chunk of memory defined by n. More...
 
void deallocate (void *p, size_type n) noexcept(detail::has_nothrow_deallocate_v< Alloc >)
 Attempts to deallocate the memory at location p. More...
 
template<typename T , typename... Args>
void construct (T *p, Args &&... args) noexcept((detail::has_construct_v< Alloc, T *, Args... > &&detail::has_nothrow_construct_v< Alloc, T *, Args... >)||std::is_nothrow_constructible_v< T, Args... >)
 Constructs an object of T with the given ...args at the given location. More...
 
template<typename T >
void destroy (T *p) noexcept((detail::has_destroy_v< Alloc, T * > &&detail::has_nothrow_destroy_v< Alloc, T * >)||std::is_nothrow_destructible_v< T >)
 Destructs an object of T at the given location. More...
 
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. More...
 
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. More...
 
Alloc & get_allocator () noexcept
 Returns a reference to the underlying allocator. More...
 
const Alloc & get_allocator () const noexcept
 Returns a const reference to the underlying allocator. More...
 
Stream & get_stream () noexcept
 Return a reference to the stream that will be used when leaks or corruption occur. More...
 
const Stream & get_stream () const noexcept
 Return a const reference to the stream that will be used when leaks or corruption occur. More...
 

Member Typedef Documentation

◆ size_type

template<typename Alloc , typename Stream >
typedef detail::get_size_type_t<Alloc> ktl::overflow< Alloc, Stream >::size_type

Constructor & Destructor Documentation

◆ overflow() [1/4]

template<typename Alloc , typename Stream >
ktl::overflow< Alloc, Stream >::overflow ( Stream &  stream)
inlineexplicitnoexcept

Construct the allocator with a reference to a stream object.

Parameters
streamThe stream to use when leaks or corruption happens

◆ overflow() [2/4]

template<typename Alloc , typename Stream >
template<typename... Args, typename = std::enable_if_t< std::is_constructible_v<Alloc, Args...>>>
ktl::overflow< Alloc, Stream >::overflow ( Stream &  stream,
Args &&...  args 
)
inlineexplicitnoexcept

Constructor for forwarding any arguments to the underlying allocator.

◆ overflow() [3/4]

template<typename Alloc , typename Stream >
ktl::overflow< Alloc, Stream >::overflow ( const overflow< Alloc, Stream > &  )
default

◆ overflow() [4/4]

template<typename Alloc , typename Stream >
ktl::overflow< Alloc, Stream >::overflow ( overflow< Alloc, Stream > &&  )
default

◆ ~overflow()

template<typename Alloc , typename Stream >
ktl::overflow< Alloc, Stream >::~overflow ( )
inline

Member Function Documentation

◆ allocate()

template<typename Alloc , typename Stream >
void* ktl::overflow< Alloc, Stream >::allocate ( size_type  n)
inlinenoexcept

Attempts to allocate a chunk of memory defined by n.

Note
Allocates 64 bytes more on either side of the returned address. This memory will be used for overflow checking.
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 Stream >
template<typename T , typename... Args>
void ktl::overflow< Alloc, Stream >::construct ( T *  p,
Args &&...  args 
)
inlinenoexcept

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

Note
Keeps track of the number of constructions
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 Stream >
void ktl::overflow< Alloc, Stream >::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 Stream >
template<typename T >
void ktl::overflow< Alloc, Stream >::destroy ( T *  p)
inlinenoexcept

Destructs an object of T at the given location.

Note
Keeps track of the number of destructions
Parameters
pThe location of the object in memory

◆ get_allocator() [1/2]

template<typename Alloc , typename Stream >
const Alloc& ktl::overflow< Alloc, Stream >::get_allocator ( ) const
inlinenoexcept

Returns a const reference to the underlying allocator.

Returns
The allocator

◆ get_allocator() [2/2]

template<typename Alloc , typename Stream >
Alloc& ktl::overflow< Alloc, Stream >::get_allocator ( )
inlinenoexcept

Returns a reference to the underlying allocator.

Returns
The allocator

◆ get_stream() [1/2]

template<typename Alloc , typename Stream >
const Stream& ktl::overflow< Alloc, Stream >::get_stream ( ) const
inlinenoexcept

Return a const reference to the stream that will be used when leaks or corruption occur.

Returns
The stream

◆ get_stream() [2/2]

template<typename Alloc , typename Stream >
Stream& ktl::overflow< Alloc, Stream >::get_stream ( )
inlinenoexcept

Return a reference to the stream that will be used when leaks or corruption occur.

Returns
The stream

◆ max_size()

template<typename Alloc , typename Stream >
template<typename A = Alloc>
std::enable_if<detail::has_max_size_v<A>, size_type>::type ktl::overflow< Alloc, Stream >::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 Stream >
bool ktl::overflow< Alloc, Stream >::operator!= ( const overflow< Alloc, Stream > &  rhs) const
inlinenoexcept

◆ operator=() [1/2]

template<typename Alloc , typename Stream >
overflow& ktl::overflow< Alloc, Stream >::operator= ( const overflow< Alloc, Stream > &  )
default

◆ operator=() [2/2]

template<typename Alloc , typename Stream >
overflow& ktl::overflow< Alloc, Stream >::operator= ( overflow< Alloc, Stream > &&  )
default

◆ operator==()

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

◆ owns()

template<typename Alloc , typename Stream >
template<typename A = Alloc>
std::enable_if<detail::has_owns_v<A>, bool>::type ktl::overflow< Alloc, Stream >::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: