COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | List of all members
comms::util::alloc::DynMemory< TInterface > Class Template Reference

#include "alloc.h"

Detailed Description

template<typename TInterface>
class comms::util::alloc::DynMemory< TInterface >

Dynamic memory allocator.

Uses standard operator "new" to allocate and initialise requested object.

Template Parameters
TInterfaceCommon interface class for all objects being allocated with this allocator.

Public Types

using Ptr = std::unique_ptr< TInterface >
 Smart pointer (std::unique_ptr) to the allocated object.
 

Static Public Member Functions

template<typename TObj , typename... TArgs>
static Ptr alloc (TArgs &&... args)
 Allocation function.
 
static constexpr bool canAllocate ()
 Inquiry whether allocation is possible.
 
template<typename TObj >
static Ptr wrap (TObj *obj)
 Function used to wrap raw pointer into a smart one.
 

Member Function Documentation

◆ alloc()

template<typename TInterface >
template<typename TObj , typename... TArgs>
static Ptr comms::util::alloc::DynMemory< TInterface >::alloc ( TArgs &&...  args)
static

Allocation function.

Template Parameters
TObjType of the object being allocated, expected to be the same as or derived from TInterface.
TArgstypes of arguments to be passed to the constructor.
Parameters
[in]argsExtra arguments to be passed to allocated object's constructor.
Returns
Smart pointer to the allocated object.

◆ canAllocate()

template<typename TInterface >
static constexpr bool comms::util::alloc::DynMemory< TInterface >::canAllocate ( )
staticconstexpr

Inquiry whether allocation is possible.

Returns
Always true.

◆ wrap()

template<typename TInterface >
template<typename TObj >
static Ptr comms::util::alloc::DynMemory< TInterface >::wrap ( TObj *  obj)
static

Function used to wrap raw pointer into a smart one.

Template Parameters
Typeof the object, expected to be the same as or derived from TInterface.
Parameters
[in]objPointer to previously allocated object.
Returns
Smart pointer to the wrapped object.

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