From 8c04edd66982f78aad903e542d59fa9ac8c3b997 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 18 Oct 2024 22:50:28 +0800 Subject: [PATCH] Added NO_COPY/NO_MOVE macros. --- inc/hgl/platform/Platform.h | 7 +++++++ inc/hgl/type/DataType.h | 1 + inc/hgl/type/object/Object.h | 5 ++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/inc/hgl/platform/Platform.h b/inc/hgl/platform/Platform.h index fbf0757..bc7b370 100644 --- a/inc/hgl/platform/Platform.h +++ b/inc/hgl/platform/Platform.h @@ -276,5 +276,12 @@ namespace hgl #else #define __HGL_FUNC__ __FUNCTION__ #endif// + + #define NO_COPY(className) className(const className &)=delete; \ + className &operator=(const className &)=delete; + + #define NO_MOVE(className) className(className &&)=delete; \ + className &operator=(className &&)=delete; + }//namespace hgl #endif//HGL_PLATFORM_INCLUDE diff --git a/inc/hgl/type/DataType.h b/inc/hgl/type/DataType.h index 40ac7b7..038ea7f 100644 --- a/inc/hgl/type/DataType.h +++ b/inc/hgl/type/DataType.h @@ -1,6 +1,7 @@ #ifndef HGL_DATATYPE_INCLUDE #define HGL_DATATYPE_INCLUDE +#include #include // 平台定义 #include // 常用宏定义 #include // 智能指针 diff --git a/inc/hgl/type/object/Object.h b/inc/hgl/type/object/Object.h index bfc92c9..bc42e6d 100644 --- a/inc/hgl/type/object/Object.h +++ b/inc/hgl/type/object/Object.h @@ -1,5 +1,5 @@ #pragma once -#include +#include #include namespace hgl @@ -25,6 +25,9 @@ namespace hgl template friend class SafePtr; template friend struct DefaultObjectAllocator; + NO_COPY(Object) + NO_MOVE(Object) + Object(const ObjectBaseInfo &obi) noexcept { object_base_info=obi; } virtual ~Object()=default;