Using lots of macros to define operators for both int24 and int types
This commit is contained in:
@@ -57,94 +57,25 @@ namespace OpenVulkano
|
||||
return *this;
|
||||
}
|
||||
|
||||
int24 operator +(const int24& val) const
|
||||
{
|
||||
return int24( (int)*this + (int)val );
|
||||
}
|
||||
#define INT24_OPERATORS(op) \
|
||||
int24 operator op(const int24& val) const { return int24( (int)*this op (int)val ); } \
|
||||
int24 operator op(const int val) const { return int24( (int)*this op val ); }
|
||||
|
||||
int24 operator -(const int24& val) const
|
||||
{
|
||||
return int24( (int)*this - (int)val );
|
||||
}
|
||||
INT24_OPERATORS(+)
|
||||
INT24_OPERATORS(-)
|
||||
INT24_OPERATORS(*)
|
||||
INT24_OPERATORS(/)
|
||||
#undef INT24_OPERATORS
|
||||
|
||||
int24 operator *(const int24& val) const
|
||||
{
|
||||
return int24( (int)*this * (int)val );
|
||||
}
|
||||
#define INT24_OPERATORS(op) \
|
||||
int24& operator op##=(const int24& val ) { *this = *this op val; return *this; } \
|
||||
int24& operator op##=(const int val ) { *this = *this op val; return *this; }
|
||||
|
||||
int24 operator /(const int24& val) const
|
||||
{
|
||||
return int24( (int)*this / (int)val );
|
||||
}
|
||||
|
||||
int24 operator +(const int val) const
|
||||
{
|
||||
return int24( (int)*this + val );
|
||||
}
|
||||
|
||||
int24 operator -(const int val) const
|
||||
{
|
||||
return int24( (int)*this - val );
|
||||
}
|
||||
|
||||
int24 operator *(const int val) const
|
||||
{
|
||||
return int24( (int)*this * val );
|
||||
}
|
||||
|
||||
int24 operator /(const int val) const
|
||||
{
|
||||
return int24( (int)*this / val );
|
||||
}
|
||||
|
||||
|
||||
int24& operator +=(const int24& val )
|
||||
{
|
||||
*this = *this + val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int24& operator -=(const int24& val )
|
||||
{
|
||||
*this = *this - val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int24& operator *=(const int24& val )
|
||||
{
|
||||
*this = *this * val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int24& operator /=(const int24& val )
|
||||
{
|
||||
*this = *this / val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int24& operator +=(const int val )
|
||||
{
|
||||
*this = *this + val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int24& operator -=(const int val )
|
||||
{
|
||||
*this = *this - val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int24& operator *=(const int val )
|
||||
{
|
||||
*this = *this * val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int24& operator /=(const int val )
|
||||
{
|
||||
*this = *this / val;
|
||||
return *this;
|
||||
}
|
||||
INT24_OPERATORS(+)
|
||||
INT24_OPERATORS(-)
|
||||
INT24_OPERATORS(*)
|
||||
INT24_OPERATORS(/)
|
||||
#undef INT24_OPERATORS
|
||||
|
||||
int24 operator >>(const int val) const
|
||||
{
|
||||
@@ -183,64 +114,16 @@ namespace OpenVulkano
|
||||
return int24( -(int)*this );
|
||||
}
|
||||
|
||||
bool operator ==(const int24& val) const
|
||||
{
|
||||
return (int)*this == (int)val;
|
||||
}
|
||||
#define INT24_OPERATORS(op) \
|
||||
bool operator op(const int24& val) const { return (int)*this op (int)val; } \
|
||||
bool operator op(const int val) const { return (int)*this op val; }
|
||||
|
||||
bool operator !=(const int24& val) const
|
||||
{
|
||||
return (int)*this != (int)val;
|
||||
}
|
||||
|
||||
bool operator >=(const int24& val) const
|
||||
{
|
||||
return (int)*this >= (int)val;
|
||||
}
|
||||
|
||||
bool operator <=(const int24& val) const
|
||||
{
|
||||
return (int)*this <= (int)val;
|
||||
}
|
||||
|
||||
bool operator >(const int24& val) const
|
||||
{
|
||||
return (int)*this > (int)val;
|
||||
}
|
||||
|
||||
bool operator <(const int24& val) const
|
||||
{
|
||||
return (int)*this < (int)val;
|
||||
}
|
||||
|
||||
bool operator ==(const int val) const
|
||||
{
|
||||
return (int)*this == val;
|
||||
}
|
||||
|
||||
bool operator !=(const int val) const
|
||||
{
|
||||
return (int)*this != val;
|
||||
}
|
||||
|
||||
bool operator >=(const int val) const
|
||||
{
|
||||
return (int)*this >= val;
|
||||
}
|
||||
|
||||
bool operator <=(const int val) const
|
||||
{
|
||||
return (int)*this <= val;
|
||||
}
|
||||
|
||||
bool operator >(const int val) const
|
||||
{
|
||||
return ((int)*this) > val;
|
||||
}
|
||||
|
||||
bool operator <(const int val) const
|
||||
{
|
||||
return (int)*this < val;
|
||||
}
|
||||
INT24_OPERATORS(==)
|
||||
INT24_OPERATORS(!=)
|
||||
INT24_OPERATORS(>=)
|
||||
INT24_OPERATORS(<=)
|
||||
INT24_OPERATORS(>)
|
||||
INT24_OPERATORS(<)
|
||||
#undef INT24_OPERATORS
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user