kDB: Knowledge DataBase
Loading...
Searching...
No Matches
knowCore::AnnotatedPointer< _T_, _Annotation_ > Class Template Reference

#include <AnnotatedPointer.h>

Public Member Functions

 AnnotatedPointer (_T_ *_t, typename _Annotation_::Type... _annotations)
 
 AnnotatedPointer (_T_ *_t)
 
_T_ * pointer ()
 
_T_ * operator* ()
 
const _T_ * operator* () const
 
std::tuple< typename _Annotation_::Type... > annotations () const
 
template<int _index_>
std::tuple_element_t< _index_, AnnotationsT > get () const
 

Detailed Description

template<typename _T_, typename... _Annotation_>
class knowCore::AnnotatedPointer< _T_, _Annotation_ >

Add annotation to a pointer.

Example of use:

The following create a new type of annotation to a pointer, which is a bool with a default true value. The intent is that if the annotation is true the pointer ownership is transfer to the called function.

template<typename _T_>
using TransferOwnershipAnnotation = knowCore::AnnotatedPointer<_T_,
Definition Forward.h:29
Definition Forward.h:47

This annotation can be used like this:

class Monitor;
using AnnotatedMonitor = TransferOwnershipAnnotation<Monitor>

And then a new instance can be created:

AnnotatedMonitor am1(new Monitor, true);
AnnotatedMonitor am2(new Monitor, false);
if(am1.get<0>()) delete *am1;
if(am2.get<0>()) delete *am2;

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