MPD: util/VarSize.hxx File Reference

MPD 0.20.18

Functions
VarSize.hxx File Reference
`#include "Alloc.hxx"`
`#include "Compiler.h"`
`#include <type_traits>`
`#include <utility>`
`#include <new>`
`#include <cstdlib>`
Include dependency graph for VarSize.hxx:

Go to the source code of this file.

## Functions
template<class T , typename... Args>
gcc_malloc T * | NewVarSize (size_t declared_tail_size, size_t real_tail_size, Args &&... args)
| Allocate and construct a variable-size object. More...
template<typename T >
gcc_nonnull_all void | DeleteVarSize (T *instance)

## Function Documentation

## ◆ DeleteVarSize()

template<typename T >

gcc_nonnull_all void DeleteVarSize | ( | T * | instance | ) |

Definition at line 75 of file VarSize.hxx.

## ◆ NewVarSize()

template<class T , typename... Args>

gcc_malloc T* NewVarSize | ( | size_t | declared_tail_size,
|  | size_t | real_tail_size,
|  | Args &&... | args
| ) |  |

Allocate and construct a variable-size object.

That is useful for example when you want to store a variable-length string as the last attribute without the overhead of a second allocation.

Template Parameters

  T | a struct/class with a variable-size last attribute

Parameters

  declared_tail_size | the declared size of the last element in #T
  real_tail_size | the real required size of the last element in #T

Definition at line 55 of file VarSize.hxx.