make binary arithmetic operators for column_t non-member.

pull/51/head
Xpol Wan 2016-06-14 17:20:49 +08:00
parent 23f65602de
commit 211cd7a363
2 changed files with 14 additions and 29 deletions

View File

@ -231,27 +231,27 @@ public:
/// <summary>
/// Return the result of adding rhs to this column.
/// </summary>
column_t operator+(const column_t &rhs);
friend column_t operator+(column_t lhs, const column_t& rhs);
/// <summary>
/// Return the result of adding rhs to this column.
/// Return the result of subtracing lhs by rhs column.
/// </summary>
column_t operator-(const column_t &rhs);
friend column_t operator-(column_t lhs, const column_t& rhs);
/// <summary>
/// Return the result of adding rhs to this column.
/// Return the result of multiply lhs by rhs column.
/// </summary>
column_t operator*(const column_t &rhs);
friend column_t operator*(column_t lhs, const column_t& rhs);
/// <summary>
/// Return the result of adding rhs to this column.
/// Return the result of divide lhs by rhs column.
/// </summary>
column_t operator/(const column_t &rhs);
friend column_t operator/(column_t lhs, const column_t& rhs);
/// <summary>
/// Return the result of adding rhs to this column.
/// Return the result of mod lhs by rhs column.
/// </summary>
column_t operator%(const column_t &rhs);
friend column_t operator%(column_t lhs, const column_t& rhs);
/// <summary>
/// Add rhs to this column and return a reference to this column.

View File

@ -252,30 +252,15 @@ column_t column_t::operator++(int) { column_t copy(index); ++(*this); return cop
/// </summary>
column_t column_t::operator--(int) { column_t copy(index); --(*this); return copy; }
/// <summary>
/// Return the result of adding rhs to this column.
/// </summary>
column_t column_t::operator+(const column_t &rhs) { column_t copy(*this); copy.index += rhs.index; return copy; }
column_t operator+(column_t lhs, const column_t& rhs) { lhs += rhs; return lhs; }
/// <summary>
/// Return the result of adding rhs to this column.
/// </summary>
column_t column_t::operator-(const column_t &rhs) { column_t copy(*this); copy.index -= rhs.index; return copy; }
column_t operator-(column_t lhs, const column_t& rhs) { lhs -= rhs; return lhs; }
/// <summary>
/// Return the result of adding rhs to this column.
/// </summary>
column_t column_t::operator*(const column_t &rhs) { column_t copy(*this); copy.index *= rhs.index; return copy; }
column_t operator*(column_t lhs, const column_t& rhs) { lhs *= rhs; return lhs; }
/// <summary>
/// Return the result of adding rhs to this column.
/// </summary>
column_t column_t::operator/(const column_t &rhs) { column_t copy(*this); copy.index /= rhs.index; return copy; }
column_t operator/(column_t lhs, const column_t& rhs) { lhs /= rhs; return lhs; }
/// <summary>
/// Return the result of adding rhs to this column.
/// </summary>
column_t column_t::operator%(const column_t &rhs) { column_t copy(*this); copy.index %= rhs.index; return copy; }
column_t operator%(column_t lhs, const column_t& rhs) { lhs %= rhs; return lhs; }
/// <summary>
/// Add rhs to this column and return a reference to this column.