AuROXTL/Include/auROXTL/AU_USING.hpp

39 lines
1.0 KiB
C++

/***
Copyright (C) 2024 Jamie Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AU_USING.hpp
Date: 2024-07-30
Author: Reece
***/
#pragma once
namespace __audetail
{
template <typename T_t>
struct __au_using
{
T_t *pThat;
using CB_t = void (T_t:: *)();
CB_t cb;
__au_using(T_t &that, CB_t cb) :
cb(cb),
pThat(&that)
{ }
__au_using(T_t *that, CB_t cb) :
cb(cb),
pThat(that)
{ }
~__au_using()
{
((pThat)->*(cb))();
}
};
}
#define AU_USING(pPointer, method) \
__audetail::__au_using<AuRemovePointer_t<AuRemoveReference_t<decltype(*pPointer)>>> AU_CONCAT(__stack_using, __COUNTER__)( \
pPointer, \
&AuRemovePointer_t<AuRemoveReference_t<decltype(*pPointer)>>::method);