Nvwa  1.1
Classes | Typedefs | Enumerations | Functions | Variables
nvwa Namespace Reference

Namespace of the nvwa project. More...

Classes

class  bad_optional_access
 Class for bad optional access exception. More...
 
class  bool_array
 Class to represent a packed boolean array. More...
 
class  breadth_first_iteration
 Iteration class for breadth-first traversal. More...
 
class  class_level_lock
 Helper class for class-level locking. More...
 
class  class_level_lock< _Host, false >
 Partial specialization that makes null locking. More...
 
class  debug_new_counter
 Counter class for on-exit leakage check. More...
 
class  debug_new_recorder
 Recorder class to remember the call context. More...
 
struct  delete_object
 Functor to delete objects pointed by a container of pointers. More...
 
class  depth_first_iteration
 Iteration class for depth-first traversal. More...
 
struct  dereference
 Functor to return objects pointed by a container of pointers. More...
 
struct  dereference_less
 Functor to compare objects pointed by a container of pointers. More...
 
class  fast_mutex
 Class for non-reentrant fast mutexes. More...
 
class  fast_mutex_autolock
 RAII lock class for fast_mutex. More...
 
class  fc_queue
 Class to represent a fixed-capacity queue. More...
 
class  file_line_reader
 Class to allow iteration over all lines of a text file. More...
 
class  fixed_mem_pool
 Class template to manipulate a fixed-size memory pool. More...
 
class  in_order_iteration
 Iteration class for in-order traversal. More...
 
class  istream_line_reader
 Class to allow iteration over all lines from an input stream. More...
 
class  mem_pool_base
 Base class for memory pools. More...
 
class  mmap_line_reader
 Class to allow iteration over all lines of a mmappable file. More...
 
struct  new_ptr_list_t
 Structure to store the position information where new occurs. More...
 
class  object_level_lock
 Helper class for object-level locking. More...
 
class  optional
 Class for optional values. More...
 
struct  output_object
 Functor to output objects pointed by a container of pointers. More...
 
struct  smart_ptr
 Declaration of policy class to generate the smart pointer type. More...
 
struct  smart_ptr< _Tp, storage_policy::shared >
 Partial specialization to get std::shared_ptr. More...
 
struct  smart_ptr< _Tp, storage_policy::unique >
 Partial specialization to get std::unique_ptr. More...
 
class  static_mem_pool
 Singleton class template to manage the allocation/deallocation of memory blocks of one specific size. More...
 
class  static_mem_pool_set
 Singleton class to maintain a set of existing instantiations of static_mem_pool. More...
 
class  tree
 Basic tree (node) class template that owns all its children. More...
 

Typedefs

typedef void(* stacktrace_print_callback_t) (FILE *fp, void **stacktrace)
 Callback type for stack trace printing. More...
 
typedef bool(* leak_whitelist_callback_t) (char const *file, int line, void *addr, void **stacktrace)
 Callback type for the leak whitelist function. More...
 

Enumerations

enum  storage_policy { storage_policy::unique, storage_policy::shared }
 _Policy class for how to store members. More...
 

Functions

int check_leaks ()
 Checks for memory leaks. More...
 
int check_mem_corruption ()
 Checks for heap corruption. More...
 
static bool print_position_from_addr (const void *addr)
 Tries printing the position information from an instruction address. More...
 
static void print_position (const void *ptr, int line)
 Prints the position information of a memory operation point. More...
 
static void print_stacktrace (void **stacktrace)
 Prints the stack backtrace. More...
 
static bool is_leak_whitelisted (new_ptr_list_t *ptr)
 Checks whether a leak should be ignored. More...
 
static void * alloc_mem (size_t size, const char *file, int line, bool is_array)
 Allocates memory and initializes control data. More...
 
static void free_pointer (void *usr_ptr, void *addr, bool is_array)
 Frees memory and adjusts pointers. More...
 
void swap (bool_array &lhs, bool_array &rhs) noexcept
 Exchanges the content of two bool_arrays. More...
 
template<class _Tp , class _Alloc >
void swap (fc_queue< _Tp, _Alloc > &lhs, fc_queue< _Tp, _Alloc > &rhs)
 Exchanges the elements of two queues. More...
 
template<storage_policy _Policy = NVWA_TREE_DEFAULT_STORAGE_POLICY, typename _Tp >
tree< typename std::decay< _Tp >::type, _Policy >::tree_ptr create_tree (_Tp &&value)
 Creates a tree without any children. More...
 
template<storage_policy _Policy = NVWA_TREE_DEFAULT_STORAGE_POLICY, typename _Tp , typename... Args>
tree< typename std::decay< _Tp >::type, _Policy >::tree_ptr create_tree (_Tp &&value, Args &&... args)
 Creates a tree with children. More...
 
template<typename _Fn >
auto lift_optional (_Fn &&f)
 Lifts a function so that it takes optionals and returns an optional. More...
 
template<typename _Fn , typename... _Opt>
constexpr auto apply (_Fn &&f, _Opt &&... args) -> decltype(has_value(args...), optional< std::decay_t< decltype(f(std::forward< _Opt >(args).value()...))>>())
 Applies a function to the values of optionals if they are all valid. More...
 
template<typename _Fn , class _Tuple >
constexpr auto apply (_Fn &&f, _Tuple &&t) -> decltype(detail::tuple_apply_impl(std::forward< _Fn >(f), std::forward< _Tuple >(t), std::make_index_sequence< std::tuple_size< std::decay_t< _Tuple >>::value >()))
 Applies the function with all elements of the typle as arguments. More...
 
template<typename _Fn , typename _T1 , typename _T2 >
constexpr auto fmap (_Fn &&f, const std::pair< _T1, _T2 > &args)
 Applies a function to both elements of a pair, and makes the results a pair. More...
 
template<typename _Fn , typename... _Targs>
constexpr auto fmap (_Fn &&f, const std::tuple< _Targs... > &args)
 Applies a function to all elements of a tuple, and makes the results a tuple. More...
 
template<template< typename, typename > class _OutCont = std::vector, template< typename > class _Alloc = std::allocator, typename _Fn , class _Rng >
constexpr auto fmap (_Fn &&f, _Rng &&inputs) -> decltype(detail::adl_begin(inputs), detail::adl_end(inputs), _OutCont< std::decay_t< decltype(f(*detail::adl_begin(inputs)))>, _Alloc< std::decay_t< decltype(f(*detail::adl_begin(inputs)))>>>())
 Applies a function to each element in the input range. More...
 
template<typename _Rs , typename _Fn , typename... _Targs>
constexpr auto reduce (_Fn &&f, const std::tuple< _Targs... > &args, _Rs &&value)
 Applies a function cumulatively to all elements of a tuple. More...
 
template<typename _Fn , class _Rng >
constexpr auto reduce (_Fn &&f, _Rng &&inputs)
 Applies a function cumulatively to elements in the input range. More...
 
template<typename _Rs , typename _Fn , typename _Iter >
constexpr _Rs && reduce (_Fn &&f, _Rs &&value, _Iter begin, _Iter end)
 Applies a function cumulatively to a range. More...
 
template<typename _Rs , typename _Fn , class _Rng >
constexpr auto reduce (_Fn &&f, _Rng &&inputs, _Rs &&initval) -> decltype(f(initval, *detail::adl_begin(inputs)))
 Applies a function cumulatively to elements in the input range. More...
 
template<typename _T1 , typename _T2 , typename _Fn >
constexpr auto wrap_args_as_pair (_Fn &&f)
 Makes a two-argument function accept a pair instead. More...
 
template<typename _Tuple , typename _Fn >
constexpr auto wrap_args_as_tuple (_Fn &&f)
 Makes a function accept a tuple as its arguments. More...
 
template<typename _Tp >
constexpr _Tp pipeline (_Tp &&data)
 Returns the data intact to terminate the recursion.
 
template<typename _Tp , typename _Fn , typename... _Fargs>
decltype(auto) constexpr pipeline (_Tp &&data, _Fn &&f, _Fargs &&... args)
 Applies the functions in the arguments to the data consecutively. More...
 
auto compose ()
 Constructs a function (object) that composes the passed functions. More...
 
template<typename _Fn >
auto compose (_Fn f)
 Constructs a function (object) that composes the passed functions. More...
 
template<typename _Fn , typename... _Fargs>
auto compose (_Fn f, _Fargs... args)
 Constructs a function (object) that composes the passed functions. More...
 
template<typename _Rs , typename _Tp >
std::function< _Rs(_Tp)> fix_simple (std::function< _Rs(std::function< _Rs(_Tp)>, _Tp)> f)
 Generates the fixed point using the simple fixed-point combinator. More...
 
template<typename _Rs , typename _Tp >
std::function< _Rs(_Tp)> fix_simple (std::function< std::function< _Rs(_Tp)>(std::function< _Rs(_Tp)>)> f)
 Generates the fixed point using the simple fixed-point combinator. More...
 
template<typename _Rs , typename _Tp >
std::function< _Rs(_Tp)> fix_curry (std::function< std::function< _Rs(_Tp)>(std::function< _Rs(_Tp)>)> f)
 Generates the fixed point using the Curry-style fixed-point combinator. More...
 
template<typename _Rs , typename... _Targs>
auto make_curry (std::function< _Rs(_Targs...)> f)
 Makes a curried function. More...
 
template<typename _Rs , typename... _Targs>
auto make_curry (_Rs(*f)(_Targs...))
 Makes a curried function. More...
 
template<typename _FnType , typename _Fn >
auto make_curry (_Fn &&f)
 Makes a curried function. More...
 

Variables

bool new_autocheck_flag = true
 Flag to control whether nvwa::check_leaks will be automatically called on program exit.
 
bool new_verbose_flag = false
 Flag to control whether verbose messages are output.
 
FILE * new_output_fp = stderr
 Pointer to the output stream. More...
 
const char * new_progname = _DEBUG_NEW_PROGNAME
 Pointer to the program name. More...
 
stacktrace_print_callback_t stacktrace_print_callback = nullptr
 Pointer to the callback used to print the stack backtrace in case of a memory problem. More...
 
leak_whitelist_callback_t leak_whitelist_callback = nullptr
 Pointer to the callback used to filter out false positives from leak reports. More...
 
static debug_new_counter __debug_new_count
 Counting object for each file including debug_new.h. More...
 
const size_t PLATFORM_MEM_ALIGNMENT = sizeof(size_t) * 2
 The platform memory alignment. More...
 
static const unsigned DEBUG_NEW_MAGIC = 0x4442474E
 Definition of the constant magic number used for error detection.
 
static const int ALIGNED_LIST_ITEM_SIZE = ALIGN(sizeof(new_ptr_list_t))
 The extra memory allocated by operator new.
 
static new_ptr_list_t new_ptr_list
 List of all new'd pointers.
 
static fast_mutex new_ptr_lock
 The mutex guard to protect simultaneous access to the pointer list.
 
static fast_mutex new_output_lock
 The mutex guard to protect simultaneous output to new_output_fp.
 
static size_t total_mem_alloc = 0
 Total memory allocated in bytes.
 
const size_t BUFFER_SIZE = 256
 Size of buffer. More...
 

Detailed Description

Namespace of the nvwa project.

Most functions and global variables are defined in this namespace.

Typedef Documentation

◆ leak_whitelist_callback_t

typedef bool(* nvwa::leak_whitelist_callback_t) (char const *file, int line, void *addr, void **stacktrace)

Callback type for the leak whitelist function.

file, address, and backtrace might be null depending on library configuration, platform, and amount of runtime information available. line can be 0 when line number info is not available at runtime.

Parameters
filenull-terminated string of the file name
lineline number
addraddress of code where leakage happens
stacktracepointer to the stack trace array (null-terminated)
Returns
true if the leak should be whitelisted; false otherwise

◆ stacktrace_print_callback_t

typedef void(* nvwa::stacktrace_print_callback_t) (FILE *fp, void **stacktrace)

Callback type for stack trace printing.

Parameters
fppointer to the output stream
stacktracepointer to the stack trace array (null-terminated)

Enumeration Type Documentation

◆ storage_policy

enum nvwa::storage_policy
strong

_Policy class for how to store members.

Enumerator
unique 

Members are directly owned.

shared 

Members may be shared and passed around.

Function Documentation

◆ alloc_mem()

static void* nvwa::alloc_mem ( size_t  size,
const char *  file,
int  line,
bool  is_array 
)
static

Allocates memory and initializes control data.

Parameters
sizesize of the required memory block
filenull-terminated string of the file name
lineline number
is_arrayboolean value whether this is an array operation
Returns
pointer to the user-requested memory area; null if memory allocation is not successful

◆ apply() [1/2]

template<typename _Fn , typename... _Opt>
constexpr auto nvwa::apply ( _Fn &&  f,
_Opt &&...  args 
) -> decltype( has_value(args...), optional< std::decay_t<decltype(f(std::forward<_Opt>(args).value()...))>>())

Applies a function to the values of optionals if they are all valid.

If any of the optionals are invalid, the result is invalid too.

Parameters
fthe function to apply
argsoptionals whose values will be passed to f
Returns
an optional that either is invalid (if any of the input is invalid) or contains the output of f

◆ apply() [2/2]

template<typename _Fn , class _Tuple >
constexpr auto nvwa::apply ( _Fn &&  f,
_Tuple &&  t 
) -> decltype(detail::tuple_apply_impl( std::forward<_Fn>(f), std::forward<_Tuple>(t), std::make_index_sequence< std::tuple_size<std::decay_t<_Tuple>>::value>()))

Applies the function with all elements of the typle as arguments.

It is exactly like the C++17 std::apply.

Parameters
fthe function to apply
tthe tuple that can expand to the function arguments
Returns
the result of the function applied

◆ check_leaks()

int nvwa::check_leaks ( )

Checks for memory leaks.

Returns
zero if no leakage is found; the number of leaks otherwise

◆ check_mem_corruption()

int nvwa::check_mem_corruption ( )

Checks for heap corruption.

Returns
zero if no problem is found; the number of found memory corruptions otherwise

◆ compose() [1/3]

auto nvwa::compose ( )

Constructs a function (object) that composes the passed functions.

Returns
the forwarding function

◆ compose() [2/3]

template<typename _Fn >
auto nvwa::compose ( _Fn  f)

Constructs a function (object) that composes the passed functions.

Parameters
fthe function to compose
Returns
the function object that composes the passed function

◆ compose() [3/3]

template<typename _Fn , typename... _Fargs>
auto nvwa::compose ( _Fn  f,
_Fargs...  args 
)

Constructs a function (object) that composes the passed functions.

Parameters
fthe last function to compose
argsthe other functions to compose
Returns
the function object that composes the passed functions

◆ create_tree() [1/2]

template<storage_policy _Policy = NVWA_TREE_DEFAULT_STORAGE_POLICY, typename _Tp >
tree<typename std::decay<_Tp>::type, _Policy>::tree_ptr nvwa::create_tree ( _Tp &&  value)

Creates a tree without any children.

Parameters
valuethe value to assign to the tree node
Returns
the unique_ptr to the newly created tree

◆ create_tree() [2/2]

template<storage_policy _Policy = NVWA_TREE_DEFAULT_STORAGE_POLICY, typename _Tp , typename... Args>
tree<typename std::decay<_Tp>::type, _Policy>::tree_ptr nvwa::create_tree ( _Tp &&  value,
Args &&...  args 
)

Creates a tree with children.

Parameters
valuethe value to assign to the tree node
argsthe unique_ptrs to children of the tree
Returns
the unique_ptr to the newly created tree

◆ fix_curry()

template<typename _Rs , typename _Tp >
std::function<_Rs(_Tp)> nvwa::fix_curry ( std::function< std::function< _Rs(_Tp)>(std::function< _Rs(_Tp)>)>  f)

Generates the fixed point using the Curry-style fixed-point combinator.

This function takes a curried function of one parameter.

Parameters
fthe second-order function to combine with
Returns
the fixed point

◆ fix_simple() [1/2]

template<typename _Rs , typename _Tp >
std::function<_Rs(_Tp)> nvwa::fix_simple ( std::function< _Rs(std::function< _Rs(_Tp)>, _Tp)>  f)

Generates the fixed point using the simple fixed-point combinator.

This function takes a non-curried function of two parameters.

Parameters
fthe second-order function to combine with
Returns
the fixed point

◆ fix_simple() [2/2]

template<typename _Rs , typename _Tp >
std::function<_Rs(_Tp)> nvwa::fix_simple ( std::function< std::function< _Rs(_Tp)>(std::function< _Rs(_Tp)>)>  f)

Generates the fixed point using the simple fixed-point combinator.

This function takes a curried function of one parameter.

Parameters
fthe second-order function to combine with
Returns
the fixed point

◆ fmap() [1/3]

template<typename _Fn , typename _T1 , typename _T2 >
constexpr auto nvwa::fmap ( _Fn &&  f,
const std::pair< _T1, _T2 > &  args 
)

Applies a function to both elements of a pair, and makes the results a pair.

Parameters
fthe function to apply
argspair of arguments to pass
Returns
pair of results of function invocation

◆ fmap() [2/3]

template<typename _Fn , typename... _Targs>
constexpr auto nvwa::fmap ( _Fn &&  f,
const std::tuple< _Targs... > &  args 
)

Applies a function to all elements of a tuple, and makes the results a tuple.

Parameters
fthe function to apply
argstuple of arguments to pass
Returns
tuple of results of function invocation

◆ fmap() [3/3]

template<template< typename, typename > class _OutCont = std::vector, template< typename > class _Alloc = std::allocator, typename _Fn , class _Rng >
constexpr auto nvwa::fmap ( _Fn &&  f,
_Rng &&  inputs 
) -> decltype( detail::adl_begin(inputs), detail::adl_end(inputs), _OutCont< std::decay_t<decltype(f(*detail::adl_begin(inputs)))>, _Alloc<std::decay_t<decltype(f(*detail::adl_begin(inputs)))>>>())

Applies a function to each element in the input range.

This is similar to std::transform, but the style is more functional and more suitable for chaining operations.

Parameters
fthe function to apply
inputsthe input range
Precondition
f shall take one argument of the type of the elements in inputs, the output container shall support push_back, and the input range shall support iteration.
Returns
the container of results

◆ free_pointer()

static void nvwa::free_pointer ( void *  usr_ptr,
void *  addr,
bool  is_array 
)
static

Frees memory and adjusts pointers.

Parameters
usr_ptrpointer to the previously allocated memory
addrpointer to the caller
is_arrayflag indicating whether it is invoked by a delete[] call

◆ is_leak_whitelisted()

static bool nvwa::is_leak_whitelisted ( new_ptr_list_t ptr)
static

Checks whether a leak should be ignored.

Its runtime performance depends on the callback nvwa::leak_whitelist_callback.

Parameters
ptrpointer to a new_ptr_list_t struct
Returns
true if the leak should be whitelisted; false otherwise

◆ lift_optional()

template<typename _Fn >
auto nvwa::lift_optional ( _Fn &&  f)

Lifts a function so that it takes optionals and returns an optional.

Parameters
ffunction to lift
Returns
the lifted function

◆ make_curry() [1/3]

template<typename _Rs , typename... _Targs>
auto nvwa::make_curry ( std::function< _Rs(_Targs...)>  f)

Makes a curried function.

The returned function takes one argument at a time, and return a function that takes the next argument until all arguments are exhausted, in which case it returns the final result. This overload takes an std::function and can deduce its argument types and return type.

Parameters
fthe function to be curried as a std::function
Returns
the curried function

◆ make_curry() [2/3]

template<typename _Rs , typename... _Targs>
auto nvwa::make_curry ( _Rs(*)(_Targs...)  f)

Makes a curried function.

The returned function takes one argument at a time, and return a function that takes the next argument until all arguments are exhausted, in which case it returns the final result. This overload takes a pointer to function and can deduce its argument types and return type.

Parameters
fthe function to be curried as a function pointer
Returns
the curried function

◆ make_curry() [3/3]

template<typename _FnType , typename _Fn >
auto nvwa::make_curry ( _Fn &&  f)

Makes a curried function.

The returned function takes one argument at a time, and return a function that takes the next argument until all arguments are exhausted, in which case it returns the final result. This overload takes a generic function object, and the function type must be specified when this function template is instantiated.

Parameters
fthe function to be curried as a function pointer
Returns
the curried function

◆ pipeline()

template<typename _Tp , typename _Fn , typename... _Fargs>
decltype(auto) constexpr nvwa::pipeline ( _Tp &&  data,
_Fn &&  f,
_Fargs &&...  args 
)

Applies the functions in the arguments to the data consecutively.

Parameters
datathe data to operate on
fthe first function to apply
argsthe rest functions to apply

◆ print_position()

static void nvwa::print_position ( const void *  ptr,
int  line 
)
static

Prints the position information of a memory operation point.

When _DEBUG_NEW_USE_ADDR2LINE is defined to a non-zero value, this function will try to convert a given caller address to file/line information with addr2line.

Parameters
ptrsource file name if line is non-zero; caller address otherwise
linesource line number if non-zero; indication that ptr is the caller address otherwise

◆ print_position_from_addr()

static bool nvwa::print_position_from_addr ( const void *  addr)
static

Tries printing the position information from an instruction address.

This is the version that uses addr2line.

Parameters
addrthe instruction address to convert and print
Returns
true if the address is converted successfully (and the result is printed); false if no useful information is got (and nothing is printed)

◆ print_stacktrace()

static void nvwa::print_stacktrace ( void **  stacktrace)
static

Prints the stack backtrace.

When nvwa::stacktrace_print_callback is not null, it is used for printing the stacktrace items. Default implementation of call stack printing is very spartan—only stack frame pointers are printed—but even that output is still useful. Just do address lookup in LLDB etc.

Parameters
stacktracepointer to the stack trace array

◆ reduce() [1/4]

template<typename _Rs , typename _Fn , typename... _Targs>
constexpr auto nvwa::reduce ( _Fn &&  f,
const std::tuple< _Targs... > &  args,
_Rs &&  value 
)

Applies a function cumulatively to all elements of a tuple.

Parameters
fthe function to apply
valuethe first argument to be passed to the function
argsthe input tuple
Precondition
f shall take one argument of the result type, and one argument of the type of the elements in args.

◆ reduce() [2/4]

template<typename _Fn , class _Rng >
constexpr auto nvwa::reduce ( _Fn &&  f,
_Rng &&  inputs 
)

Applies a function cumulatively to elements in the input range.

This is similar to std::accumulate, but the style is more functional and more suitable for chaining operations.

Parameters
fthe function to apply
inputsthe input range
Precondition
f shall take two arguments of the type of the elements in inputs, and the input range shall support iteration.

◆ reduce() [3/4]

template<typename _Rs , typename _Fn , typename _Iter >
constexpr _Rs&& nvwa::reduce ( _Fn &&  f,
_Rs &&  value,
_Iter  begin,
_Iter  end 
)

Applies a function cumulatively to a range.

This is similar to std::accumulate, but the interface is different, and f is allowed to have arguments of different types (the first argument shall have the same type as the function return type). Perfect forwarding allows the result to be a reference type.

Parameters
fthe function to apply
valuethe first argument to be passed to f
beginbeginning of the range
endend of the range
Precondition
f shall take one argument of the result type, and one argument of the type of the elements in inputs, and the input range shall support iteration.

◆ reduce() [4/4]

template<typename _Rs , typename _Fn , class _Rng >
constexpr auto nvwa::reduce ( _Fn &&  f,
_Rng &&  inputs,
_Rs &&  initval 
) -> decltype(f(initval, *detail::adl_begin(inputs)))

Applies a function cumulatively to elements in the input range.

This is similar to std::accumulate, but the style is more functional and more suitable for chaining operations. This implementation allows the two arguments of f to have different types (the first argument shall have the same type as the function return type). Perfect forwarding allows the result to be a reference type, and it is possible to write code like:

// Declaration of the output function
std::ostream& print(std::ostream& os, const my_type&);
// Dump all contents of the container_of_my_type to cout
nvwa::reduce(print, container_of_my_type, std::cout);
Parameters
fthe function to apply
inputsthe input range
initvalinitial value for the cumulative calculation
Precondition
f shall take one argument of the result type, and one argument of the type of the elements in inputs, and the input range shall support iteration.

◆ swap() [1/2]

void nvwa::swap ( bool_array lhs,
bool_array rhs 
)
inlinenoexcept

Exchanges the content of two bool_arrays.

Parameters
lhsthe first bool_array to exchange
rhsthe second bool_array to exchange

◆ swap() [2/2]

template<class _Tp , class _Alloc >
void nvwa::swap ( fc_queue< _Tp, _Alloc > &  lhs,
fc_queue< _Tp, _Alloc > &  rhs 
)

Exchanges the elements of two queues.

Parameters
lhsthe first queue to exchange
rhsthe second queue to exchange
Postcondition
If swapping the allocators does not throw, lhs will be swapped with rhs. If swapping the allocators throws with strong exception safety guarantee, this function will also provide such guarantee.

◆ wrap_args_as_pair()

template<typename _T1 , typename _T2 , typename _Fn >
constexpr auto nvwa::wrap_args_as_pair ( _Fn &&  f)

Makes a two-argument function accept a pair instead.

Parameters
fa function that accepts two arguments
Returns
a function that accepts a pair

◆ wrap_args_as_tuple()

template<typename _Tuple , typename _Fn >
constexpr auto nvwa::wrap_args_as_tuple ( _Fn &&  f)

Makes a function accept a tuple as its arguments.

The tuple shall contain exactly the same type/number of argument as the function needs.

Parameters
fa function that accepts two arguments
Returns
a function that accepts a pair

Variable Documentation

◆ __debug_new_count

debug_new_counter nvwa::__debug_new_count
static

Counting object for each file including debug_new.h.

◆ BUFFER_SIZE

const size_t nvwa::BUFFER_SIZE = 256

Size of buffer.

◆ leak_whitelist_callback

leak_whitelist_callback_t nvwa::leak_whitelist_callback = nullptr

Pointer to the callback used to filter out false positives from leak reports.

A null value means the lack of filtering.

◆ new_output_fp

FILE * nvwa::new_output_fp = stderr

Pointer to the output stream.

The default output is stderr, and one may change it to a user stream if needed (say, new_verbose_flag is true and there are a lot of (de)allocations).

◆ new_progname

const char * nvwa::new_progname = _DEBUG_NEW_PROGNAME

Pointer to the program name.

Its initial value is the macro _DEBUG_NEW_PROGNAME. You should try to assign the program path to it early in your application. Assigning argv[0] to it in main is one way. If you use bash or ksh (or similar), the following statement is probably what you want: `new_progname = getenv("_");'.

◆ PLATFORM_MEM_ALIGNMENT

const size_t nvwa::PLATFORM_MEM_ALIGNMENT = sizeof(size_t) * 2

The platform memory alignment.

The current value works well in platforms I have tested: Windows XP, Windows 7 x64, and Mac OS X Leopard. It may be smaller than the real alignment, but must be bigger than sizeof(size_t) for it work. nvwa::debug_new_recorder uses it to detect misaligned pointer returned by `new NonPODType[size]'.

◆ stacktrace_print_callback

stacktrace_print_callback_t nvwa::stacktrace_print_callback = nullptr

Pointer to the callback used to print the stack backtrace in case of a memory problem.

A null value causes the default stack trace printing routine to be used.