From f114032e5380d6548d9f2029fbf1fa6c980ae415 Mon Sep 17 00:00:00 2001 From: "HuYingzhuo(hugo/hyzboy)" Date: Wed, 7 Jun 2023 20:57:07 +0800 Subject: [PATCH] added const postfix at Size2<> --- inc/hgl/type/Size2.h | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/inc/hgl/type/Size2.h b/inc/hgl/type/Size2.h index b89d7b3..c827307 100644 --- a/inc/hgl/type/Size2.h +++ b/inc/hgl/type/Size2.h @@ -1,11 +1,11 @@ -#pragma once +#pragma once #include namespace hgl { /** - * ߴģ + * 尺寸模板 */ template struct Size2 { @@ -24,8 +24,8 @@ namespace hgl height=h; } - const bool isLandscape()const{return width>height;} ///<Ƿ - const bool isPortrait()const{return widthheight;} ///<是否横的 + const bool isPortrait()const{return width Swapped(){return Size2(height,width);} ///<ȡһijߴ + Size2 Swapped()const{return Size2(height,width);} ///<获取一个横竖交换的尺寸 + + const bool operator == (const Size2 &s) const + { + if(width!=s.width)return(false); + if(height!=s.height)return(false); + return(true); + } + + const bool operator != (const Size2 &s) const + { + return !operator==(s); + } };//template struct Size2 using Size2i =Size2;