crap/include/Dumber.hpp
2015-06-10 23:57:19 -07:00

85 lines
1.2 KiB
C++

// Presenting: Dumber, the dumb number
// this is just some C++ bloat-i-mean-boilerplate
// for inheritance in vector types.
TEMPLATE
struct DumberBase {
T v;
inline
DumberBase()
{}
inline
DumberBase(T v2)
{ v = v2; }
inline
DumberBase(const DumberBase &x)
{ v = x.v; }
inline DumberBase&
operator=(const DumberBase& v2) {
v = v2.v;
return *this;
}
inline DumberBase
operator-()
{ return -v; }
inline DumberBase
operator+(const DumberBase &v2)
{ return v + v2.v; }
inline DumberBase
operator-(const DumberBase &v2)
{ return v - v2.v; }
inline DumberBase
operator*(const DumberBase &v2)
{ return v*v2.v; }
inline DumberBase
operator/(const DumberBase &v2)
{ return v/v2.v; }
inline DumberBase&
operator+=(const DumberBase &v2)
{
v = v + v2.v;
return *this;
}
inline DumberBase&
operator-=(const DumberBase &v2)
{
v = v - v2.v;
return *this;
}
inline DumberBase&
operator*=(const DumberBase &v2)
{
v = v*v2.v;
return *this;
}
inline DumberBase&
operator/=(const DumberBase &v2)
{
v = v/v2.v;
return *this;
}
};
TEMPLATE
struct Dumber : public DumberBase<T> {
inline
Dumber()
{}
inline
Dumber(DumberBase<T> v2) : DumberBase<T>(v2)
{}
};