Change to pass by reference

This commit is contained in:
chinhodado 2014-11-14 22:26:28 -05:00
parent 22515d1b05
commit 3a15da48ac

View File

@ -115,7 +115,6 @@ protected:
public:
T const swap() const {
return swap(value);
}
swap_struct_t() : value((T)0) {}
swap_struct_t(const T &v): value(swap(v)) {}
@ -377,126 +376,126 @@ public:
// Arithmetics
template <typename S, typename T2, typename F2>
friend S operator+(const S &p, const swapped_t v);
friend S operator+(const S &p, const swapped_t& v);
template <typename S, typename T2, typename F2>
friend S operator-(const S &p, const swapped_t v);
friend S operator-(const S &p, const swapped_t& v);
template <typename S, typename T2, typename F2>
friend S operator/(const S &p, const swapped_t v);
friend S operator/(const S &p, const swapped_t& v);
template <typename S, typename T2, typename F2>
friend S operator*(const S &p, const swapped_t v);
friend S operator*(const S &p, const swapped_t& v);
template <typename S, typename T2, typename F2>
friend S operator%(const S &p, const swapped_t v);
friend S operator%(const S &p, const swapped_t& v);
// Arithmetics + assignements
template <typename S, typename T2, typename F2>
friend S operator+=(const S &p, const swapped_t v);
friend S operator+=(const S &p, const swapped_t& v);
template <typename S, typename T2, typename F2>
friend S operator-=(const S &p, const swapped_t v);
friend S operator-=(const S &p, const swapped_t& v);
// Bitmath
template <typename S, typename T2, typename F2>
friend S operator&(const S &p, const swapped_t v);
friend S operator&(const S &p, const swapped_t& v);
// Comparison
template <typename S, typename T2, typename F2>
friend bool operator<(const S &p, const swapped_t v);
friend bool operator<(const S &p, const swapped_t& v);
template <typename S, typename T2, typename F2>
friend bool operator>(const S &p, const swapped_t v);
friend bool operator>(const S &p, const swapped_t& v);
template <typename S, typename T2, typename F2>
friend bool operator<=(const S &p, const swapped_t v);
friend bool operator<=(const S &p, const swapped_t& v);
template <typename S, typename T2, typename F2>
friend bool operator>=(const S &p, const swapped_t v);
friend bool operator>=(const S &p, const swapped_t& v);
template <typename S, typename T2, typename F2>
friend bool operator!=(const S &p, const swapped_t v);
friend bool operator!=(const S &p, const swapped_t& v);
template <typename S, typename T2, typename F2>
friend bool operator==(const S &p, const swapped_t v);
friend bool operator==(const S &p, const swapped_t& v);
};
// Arithmetics
template <typename S, typename T, typename F>
S operator+(const S &i, const swap_struct_t<T, F> v) {
S operator+(const S &i, const swap_struct_t<T, F>& v) {
return i + v.swap();
}
template <typename S, typename T, typename F>
S operator-(const S &i, const swap_struct_t<T, F> v) {
S operator-(const S &i, const swap_struct_t<T, F>& v) {
return i - v.swap();
}
template <typename S, typename T, typename F>
S operator/(const S &i, const swap_struct_t<T, F> v) {
S operator/(const S &i, const swap_struct_t<T, F>& v) {
return i / v.swap();
}
template <typename S, typename T, typename F>
S operator*(const S &i, const swap_struct_t<T, F> v) {
S operator*(const S &i, const swap_struct_t<T, F>& v) {
return i * v.swap();
}
template <typename S, typename T, typename F>
S operator%(const S &i, const swap_struct_t<T, F> v) {
S operator%(const S &i, const swap_struct_t<T, F>& v) {
return i % v.swap();
}
// Arithmetics + assignements
template <typename S, typename T, typename F>
S &operator+=(S &i, const swap_struct_t<T, F> v) {
S &operator+=(S &i, const swap_struct_t<T, F>& v) {
i += v.swap();
return i;
}
template <typename S, typename T, typename F>
S &operator-=(S &i, const swap_struct_t<T, F> v) {
S &operator-=(S &i, const swap_struct_t<T, F>& v) {
i -= v.swap();
return i;
}
// Logical
template <typename S, typename T, typename F>
S operator&(const S &i, const swap_struct_t<T, F> v) {
S operator&(const S &i, const swap_struct_t<T, F>& v) {
return i & v.swap();
}
template <typename S, typename T, typename F>
S operator&(const swap_struct_t<T, F> v, const S &i) {
S operator&(const swap_struct_t<T, F>& v, const S &i) {
return (S)(v.swap() & i);
}
// Comparaison
template <typename S, typename T, typename F>
bool operator<(const S &p, const swap_struct_t<T, F> v) {
bool operator<(const S &p, const swap_struct_t<T, F>& v) {
return p < v.swap();
}
template <typename S, typename T, typename F>
bool operator>(const S &p, const swap_struct_t<T, F> v) {
bool operator>(const S &p, const swap_struct_t<T, F>& v) {
return p > v.swap();
}
template <typename S, typename T, typename F>
bool operator<=(const S &p, const swap_struct_t<T, F> v) {
bool operator<=(const S &p, const swap_struct_t<T, F>& v) {
return p <= v.swap();
}
template <typename S, typename T, typename F>
bool operator>=(const S &p, const swap_struct_t<T, F> v) {
bool operator>=(const S &p, const swap_struct_t<T, F>& v) {
return p >= v.swap();
}
template <typename S, typename T, typename F>
bool operator!=(const S &p, const swap_struct_t<T, F> v) {
bool operator!=(const S &p, const swap_struct_t<T, F>& v) {
return p != v.swap();
}
template <typename S, typename T, typename F>
bool operator==(const S &p, const swap_struct_t<T, F> v) {
bool operator==(const S &p, const swap_struct_t<T, F>& v) {
return p == v.swap();
}