From 9dd89aa5a34ef90b983895d32645df9b53cce955 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Sun, 26 Jan 2025 10:23:46 +0800 Subject: [PATCH] Added Inherit.h --- inc/hgl/type/Inherit.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 inc/hgl/type/Inherit.h diff --git a/inc/hgl/type/Inherit.h b/inc/hgl/type/Inherit.h new file mode 100644 index 0000000..4c9bcc2 --- /dev/null +++ b/inc/hgl/type/Inherit.h @@ -0,0 +1,30 @@ +#pragma once +#include +#include + +namespace hgl +{ + template class Inherit:public ParentClass + { + public: + + template Inherit(ARGS...args):ParentClass(args...) {} + + virtual ~Inherit()=default; + + template static SharedPtr CreateObject(ARGS &&...args) + { + SubClass *sc=new SubClass(args...); + + return SharedPtr(sc); + } + + const size_t sizeofObject()const noexcept override { return sizeof(SubClass); } + const char * className ()const noexcept override { return typeid(SubClass).name(); } + const size_t classHash ()const noexcept override { return typeid(SubClass).hash_code(); } + };//template class Inherit + + template class Inherit<_Object,SubClass>:public _Object + { + }; +}//namespace hgl