Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54355 - sandbox/itl/boost/itl
From: afojgo_at_[hidden]
Date: 2009-06-25 16:48:27


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

Log:
Refactoring: Implemented all infix operators .o. using pass by value and RVO. Stable {msvc-9.0}
Text files modified:
   sandbox/itl/boost/itl/operators.hpp | 55 ++++++++++++++++------------------------
   1 files changed, 22 insertions(+), 33 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:48:26 EDT (Thu, 25 Jun 2009)
@@ -40,10 +40,9 @@
 
 
 template<class ObjectT>
-ObjectT operator + (const typename ObjectT::overloadable_type& object, const ObjectT& operand)
+ObjectT operator + (typename ObjectT::overloadable_type object, const ObjectT& operand)
 {
- ObjectT tmp(object);
- return tmp += operand;
+ return object += operand;
 }
 
 
@@ -59,26 +58,23 @@
 
 template<class ObjectT, class OperandT>
 typename boost::enable_if<is_binary_intra_combinable<ObjectT, OperandT>, ObjectT>::type
-operator | (const ObjectT& object, const OperandT& 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;
 }
 
 
 template<class ObjectT>
-ObjectT operator | (const typename ObjectT::overloadable_type& object, const ObjectT& operand)
+ObjectT operator | (typename ObjectT::overloadable_type object, const ObjectT& operand)
 {
- ObjectT result(object);
- return result += operand;
+ return object += operand;
 }
 
 
@@ -100,10 +96,9 @@
 
 template<class ObjectT, class OperandT>
 typename boost::enable_if<is_right_inter_combinable<ObjectT, OperandT>, ObjectT>::type
-operator - (const ObjectT& object, const OperandT& operand)
+operator - (ObjectT object, const OperandT& operand)
 {
- ObjectT result(object);
- return result -= operand;
+ return object -= operand;
 }
 
 //------------------------------------------------------------------------------
@@ -121,25 +116,22 @@
 
 template<class ObjectT, class OperandT>
 typename boost::enable_if<is_binary_inter_combinable<ObjectT, OperandT>, ObjectT>::type
-operator & (const ObjectT& object, const OperandT& 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_inter_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;
 }
 
 template<class ObjectT>
-ObjectT operator & (const typename ObjectT::overloadable_type& object, const ObjectT& operand)
+ObjectT operator & (typename ObjectT::overloadable_type object, const ObjectT& operand)
 {
- ObjectT result(object);
- return result &= operand;
+ return object &= operand;
 }
 
 //------------------------------------------------------------------------------
@@ -154,26 +146,23 @@
 
 template<class ObjectT, class OperandT>
 typename boost::enable_if<is_binary_intra_combinable<ObjectT, OperandT>, ObjectT>::type
-operator ^ (const ObjectT& object, const OperandT& 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;
 }
 
 
 template<class ObjectT>
-ObjectT operator ^ (const typename ObjectT::overloadable_type& object, const ObjectT& operand)
+ObjectT operator ^ (typename ObjectT::overloadable_type object, const ObjectT& operand)
 {
- ObjectT result(object);
- return result ^= operand;
+ return object ^= operand;
 }
 
 


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