summaryrefslogtreecommitdiff
path: root/modules/core
diff options
context:
space:
mode:
Diffstat (limited to 'modules/core')
-rw-r--r--modules/core/c++/common.hpp26
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.