diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-07-04 16:32:14 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-07-04 16:32:14 +0200 |
commit | 40369c781e43282992e720efaaa99fa5e60c0d20 (patch) | |
tree | 3a862e006b000adf3aec77334a62eef8eb6215f4 /modules/core/c++ | |
parent | 596964ba245e17444baa196c16b4531c03f7a4b2 (diff) |
Preparation work for loopback
Diffstat (limited to 'modules/core/c++')
-rw-r--r-- | modules/core/c++/common.hpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/modules/core/c++/common.hpp b/modules/core/c++/common.hpp index 40b2c43..ebca498 100644 --- a/modules/core/c++/common.hpp +++ b/modules/core/c++/common.hpp @@ -40,6 +40,32 @@ template <typename T> using our = std::shared_ptr<T>; template <typename T> using lent = std::weak_ptr<T>; +template<typename T> +class ptr { +private: + T* ptr_; + +public: + ptr(T& ptr__): + ptr_{&ptr__} + {} + + SAW_DEFAULT_COPY(ptr); + SAW_DEFAULT_MOVE(ptr); + + T& operator()(){ + return *ptr_; + } + + const T& operator()() const { + return *ptr_; + } + + bool is_valid() const { + return ptr_ != nullptr; + } +}; + /** * Reference class for easier distinction * of references and its referenced types. |