GraceFt v2.3
开源图形引擎 EGE(Easy Graphics Engine) 的高层封装库
 
载入中...
搜索中...
未找到
GFt::Size< T > 模板类 参考

泛型尺寸类 更多...

#include <Size.hpp>

Public 成员函数

constexpr Size (const Size &)=default
 
constexpr Size (Size &&)=default
 
constexpr Size (T width=static_cast< T >(0), T height=static_cast< T >(0))
 构造函数
 
constexpr T area () const
 求尺寸的面积
 
constexpr Theight ()
 尺寸的高度
 
constexpr const Theight () const
 尺寸高度的 const 版本
 
constexpr operator bool () const
 转换尺寸到 bool 值
 
template<typename U >
requires std::is_arithmetic_v<U>
constexpr operator Size< U > () const
 类型转换函数
 
constexpr bool operator! () const
 逻辑非运算符重载
 
constexpr bool operator!= (const Size &other) const
 不等于比较运算符重载
 
constexpr Size operator* (T scalar) const
 乘法运算符重载
 
constexpr Sizeoperator*= (T scalar)
 乘且赋值运算符重载
 
constexpr Size operator+ () const
 正号运算符重载
 
constexpr Size operator+ (const Size &other) const
 加法运算符重载
 
constexpr Sizeoperator+= (const Size &other)
 加且赋值运算符重载
 
constexpr Size operator- () const
 负号运算符重载
 
constexpr Size operator- (const Size &other) const
 减法运算符重载
 
constexpr Sizeoperator-= (const Size &other)
 减且赋值运算符重载
 
constexpr Size operator/ (T scalar) const
 除法运算符重载
 
constexpr Sizeoperator/= (T scalar)
 除且赋值运算符重载
 
constexpr Sizeoperator= (const Size &)=default
 
constexpr Sizeoperator= (Size &&)=default
 
constexpr bool operator== (const Size &other) const
 等于比较运算符重载
 
constexpr T perimeter () const
 求此尺寸的周长
 
constexpr Twidth ()
 尺寸的宽度
 
constexpr const Twidth () const
 尺寸宽度的 const 版本
 

友元

constexpr Size operator* (T scalar, const Size &size)
 乘法运算符重载
 
std::ostream & operator<< (std::ostream &os, const Size &size)
 流操作符重载
 

详细描述

template<typename T>
requires std::is_arithmetic_v<T>
class GFt::Size< T >

泛型尺寸类

此类用于表示一个矩形大小的几何信息,并提供常见几何操作

此类是 基础设施库 => 复合数据类型 的一部分

模板参数
T点的坐标类型,要求为算术类型

构造及析构函数说明

◆ Size() [1/3]

template<typename T >
GFt::Size< T >::Size ( T width = static_cast<T>(0),
T height = static_cast<T>(0) )
inlineexplicitconstexpr

构造函数

参数
width宽度
height高度

默认均初始化为 0

◆ Size() [2/3]

template<typename T >
GFt::Size< T >::Size ( const Size< T > & )
constexprdefault

◆ Size() [3/3]

template<typename T >
GFt::Size< T >::Size ( Size< T > && )
constexprdefault

成员函数说明

◆ area()

template<typename T >
T GFt::Size< T >::area ( ) const
inlineconstexpr

求尺寸的面积

返回
尺寸的面积

◆ height() [1/2]

template<typename T >
T & GFt::Size< T >::height ( )
inlineconstexpr

尺寸的高度

返回
高度

◆ height() [2/2]

template<typename T >
const T & GFt::Size< T >::height ( ) const
inlineconstexpr

尺寸高度的 const 版本

返回
高度

◆ operator bool()

template<typename T >
GFt::Size< T >::operator bool ( ) const
inlineexplicitconstexpr

转换尺寸到 bool 值

若 width 或 height 不全为 0,则返回 true,否则返回 false

返回
转换结果

◆ operator Size< U >()

template<typename T >
template<typename U >
requires std::is_arithmetic_v<U>
GFt::Size< T >::operator Size< U > ( ) const
inlineconstexpr

类型转换函数

模板参数
U目标类型
返回
转换后的尺寸对象

◆ operator!()

template<typename T >
bool GFt::Size< T >::operator! ( ) const
inlineconstexpr

逻辑非运算符重载

若 width 或 height 不全为 0,则返回 false,否则返回 true

返回
逻辑非运算结果

◆ operator!=()

template<typename T >
bool GFt::Size< T >::operator!= ( const Size< T > & other) const
inlineconstexpr

不等于比较运算符重载

此函数对于浮点数比较是安全的

参数
other另一个尺寸对象
返回
两个尺寸对象是否不相等

◆ operator*()

template<typename T >
Size GFt::Size< T >::operator* ( T scalar) const
inlineconstexpr

乘法运算符重载

参数
scalar标量值
返回
尺寸对象乘以标量后的结果

◆ operator*=()

template<typename T >
Size & GFt::Size< T >::operator*= ( T scalar)
inlineconstexpr

乘且赋值运算符重载

参数
scalar标量值
返回
尺寸对象乘以标量后的结果

◆ operator+() [1/2]

template<typename T >
Size GFt::Size< T >::operator+ ( ) const
inlineconstexpr

正号运算符重载

返回
尺寸对象本身

◆ operator+() [2/2]

template<typename T >
Size GFt::Size< T >::operator+ ( const Size< T > & other) const
inlineconstexpr

加法运算符重载

参数
other另一个尺寸对象
返回
两个尺寸对象的和

◆ operator+=()

template<typename T >
Size & GFt::Size< T >::operator+= ( const Size< T > & other)
inlineconstexpr

加且赋值运算符重载

参数
other另一个尺寸对象
返回
尺寸对象加上另一个尺寸对象后的结果

◆ operator-() [1/2]

template<typename T >
Size GFt::Size< T >::operator- ( ) const
inlineconstexpr

负号运算符重载

返回
尺寸对象的取反结果

◆ operator-() [2/2]

template<typename T >
Size GFt::Size< T >::operator- ( const Size< T > & other) const
inlineconstexpr

减法运算符重载

参数
other另一个尺寸对象
返回
两个尺寸对象的差

◆ operator-=()

template<typename T >
Size & GFt::Size< T >::operator-= ( const Size< T > & other)
inlineconstexpr

减且赋值运算符重载

参数
other另一个尺寸对象
返回
尺寸对象减去另一个尺寸对象后的结果

◆ operator/()

template<typename T >
Size GFt::Size< T >::operator/ ( T scalar) const
inlineconstexpr

除法运算符重载

参数
scalar标量值
返回
尺寸对象除以标量后的结果

◆ operator/=()

template<typename T >
Size & GFt::Size< T >::operator/= ( T scalar)
inlineconstexpr

除且赋值运算符重载

参数
scalar标量值
返回
尺寸对象除以标量后的结果

◆ operator=() [1/2]

template<typename T >
Size & GFt::Size< T >::operator= ( const Size< T > & )
constexprdefault

◆ operator=() [2/2]

template<typename T >
Size & GFt::Size< T >::operator= ( Size< T > && )
constexprdefault

◆ operator==()

template<typename T >
bool GFt::Size< T >::operator== ( const Size< T > & other) const
inlineconstexpr

等于比较运算符重载

此函数对于浮点数比较是安全的

参数
other另一个尺寸对象
返回
两个尺寸对象是否相等

◆ perimeter()

template<typename T >
T GFt::Size< T >::perimeter ( ) const
inlineconstexpr

求此尺寸的周长

返回
尺寸的周长

◆ width() [1/2]

template<typename T >
T & GFt::Size< T >::width ( )
inlineconstexpr

尺寸的宽度

返回
宽度

◆ width() [2/2]

template<typename T >
const T & GFt::Size< T >::width ( ) const
inlineconstexpr

尺寸宽度的 const 版本

返回
宽度

友元及相关符号说明

◆ operator*

template<typename T >
Size operator* ( T scalar,
const Size< T > & size )
friend

乘法运算符重载

参数
scalar标量值
返回
标量值乘以尺寸对象后的结果

◆ operator<<

template<typename T >
std::ostream & operator<< ( std::ostream & os,
const Size< T > & size )
friend

流操作符重载

参数
os输出流
size尺寸对象
返回
输出流 os