#ifndef OBJECT_PROXY_HPP #define OBJECT_PROXY_HPP #include namespace matador::object { class basic_object_proxy { public: virtual ~basic_object_proxy() = default; [[nodiscard]] virtual void *get() const = 0; }; template class object_proxy : public basic_object_proxy { public: object_proxy() = default; explicit object_proxy(Type* obj) : obj_(obj) {} explicit object_proxy(std::unique_ptr obj) : obj_(std::move(obj)) {} [[nodiscard]] void *get() const override { return static_cast(obj_.get()); } Type* operator->() const { return obj_.get(); } Type& operator*() { return *obj_; } const Type& operator*() const { return *obj_; } Type* pointer() const { return obj_.get(); } Type& ref() { return *obj_; } const Type& ref() const { return *obj_; } void reset(Type* obj) { obj_.reset(obj); } private: std::unique_ptr obj_{}; }; } #endif //OBJECT_PROXY_HPP