diff --git a/Include/auROXTL/AU_MACROS.hpp b/Include/auROXTL/AU_MACROS.hpp index bc69691..2ea227e 100644 --- a/Include/auROXTL/AU_MACROS.hpp +++ b/Include/auROXTL/AU_MACROS.hpp @@ -289,3 +289,5 @@ struct AuStringOwnedException : AuStringException #define AU_EMIT_FIRST_COMMA_OTHERS(n),n #include "Objects/Objects.hpp" + +#include "AU_USING.hpp" \ No newline at end of file diff --git a/Include/auROXTL/AU_USING.hpp b/Include/auROXTL/AU_USING.hpp new file mode 100644 index 0000000..f2cd939 --- /dev/null +++ b/Include/auROXTL/AU_USING.hpp @@ -0,0 +1,39 @@ +/*** + 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 + 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>> AU_CONCAT(__stack_using, __COUNTER__)( \ + pPointer, \ + &AuRemovePointer_t>::method); \ No newline at end of file