Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54354 - in sandbox/itl: boost/itl libs/itl/test/test_itl_interval
From: afojgo_at_[hidden]
Date: 2009-06-25 16:08:53


Author: jofaber
Date: 2009-06-25 16:08:52 EDT (Thu, 25 Jun 2009)
New Revision: 54354
URL: http://svn.boost.org/trac/boost/changeset/54354

Log:
Refactoring: Implemented infix operator + using pass by value and RVO. Stable {msvc-9.0}
Text files modified:
   sandbox/itl/boost/itl/operators.hpp | 12 ++++--------
   sandbox/itl/libs/itl/test/test_itl_interval/test_itl_interval.cpp | 2 --
   2 files changed, 4 insertions(+), 10 deletions(-)

Modified: sandbox/itl/boost/itl/operators.hpp
==============================================================================
--- sandbox/itl/boost/itl/operators.hpp (original)
+++ sandbox/itl/boost/itl/operators.hpp 2009-06-25 16:08:52 EDT (Thu, 25 Jun 2009)
@@ -26,20 +26,16 @@
 
 template<class ObjectT, class OperandT>
 typename boost::enable_if<is_binary_intra_combinable<ObjectT, OperandT>, ObjectT>::type
-operator + (const ObjectT& object, const OperandT& operand)
-//NOTE: Prefered implementation using return value optimization does not compile with gcc
-//{ return ObjectT(object) += operand; }
+operator + (ObjectT object, const OperandT& operand)
 {
- ObjectT result(object);
- return result += operand;
+ return object += operand;
 }
 
 template<class ObjectT, class OperandT>
 typename boost::enable_if<is_binary_intra_combinable<ObjectT, OperandT>, ObjectT>::type
-operator + (const OperandT& operand, const ObjectT& object)
+operator + (const OperandT& operand, ObjectT object)
 {
- ObjectT result(object);
- return result += operand;
+ return object += operand;
 }
 
 

Modified: sandbox/itl/libs/itl/test/test_itl_interval/test_itl_interval.cpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_itl_interval/test_itl_interval.cpp (original)
+++ sandbox/itl/libs/itl/test/test_itl_interval/test_itl_interval.cpp 2009-06-25 16:08:52 EDT (Thu, 25 Jun 2009)
@@ -371,10 +371,8 @@
     T v2 = make<T>(2);
     T v3 = make<T>(3);
     T v4 = make<T>(4);
- T v5 = make<T>(5);
     T v6 = make<T>(6);
     T v7 = make<T>(7);
- T v9 = make<T>(9);
 
     interval<T> diff_1, diff_2;
     interval<T> I0_3D = interval<T>::rightopen(v0,v3);


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk