diff options
Diffstat (limited to 'decoder/logval.h')
-rw-r--r-- | decoder/logval.h | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/decoder/logval.h b/decoder/logval.h index 7099b9be..622b308e 100644 --- a/decoder/logval.h +++ b/decoder/logval.h @@ -79,32 +79,29 @@ class LogVal { T v_; }; +// copy elision - as opposed to explicit copy of LogVal<T> const& o1, we should be able to construct Logval r=a+(b+c) as a single result in place in r. todo: return std::move(o1) - C++0x template<typename T> -LogVal<T> operator+(const LogVal<T>& o1, const LogVal<T>& o2) { - LogVal<T> res(o1); - res += o2; - return res; +LogVal<T> operator+(LogVal<T> o1, const LogVal<T>& o2) { + o1 += o2; + return o1; } template<typename T> -LogVal<T> operator*(const LogVal<T>& o1, const LogVal<T>& o2) { - LogVal<T> res(o1); - res *= o2; - return res; +LogVal<T> operator*(LogVal<T> o1, const LogVal<T>& o2) { + o1 *= o2; + return o1; } template<typename T> -LogVal<T> operator/(const LogVal<T>& o1, const LogVal<T>& o2) { - LogVal<T> res(o1); - res /= o2; - return res; +LogVal<T> operator/(LogVal<T> o1, const LogVal<T>& o2) { + o1 /= o2; + return o1; } template<typename T> -LogVal<T> operator-(const LogVal<T>& o1, const LogVal<T>& o2) { - LogVal<T> res(o1); - res -= o2; - return res; +LogVal<T> operator-(LogVal<T> o1, const LogVal<T>& o2) { + o1 -= o2; + return o1; } template<typename T> |