Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76235 - in trunk: boost/icl/concept libs/icl/test libs/icl/test/test_casual_
From: afojgo_at_[hidden]
Date: 2011-12-30 15:53:13


Author: jofaber
Date: 2011-12-30 15:53:12 EST (Fri, 30 Dec 2011)
New Revision: 76235
URL: http://svn.boost.org/trac/boost/changeset/76235

Log:
Added move semantics for T operators(...) according to the Dave-Abrahams-Transformation
(http://cpp-next.com/archive/2009/09/making-your-next-move/). Worked like a charm ;)
Text files modified:
   trunk/boost/icl/concept/interval_associator.hpp | 315 +++++++++++++++++++++++++++++++++++++++
   trunk/libs/icl/test/test_casual_/test_casual.cpp | 52 ------
   trunk/libs/icl/test/vc10_icl_fast_tests.sln | 6
   3 files changed, 323 insertions(+), 50 deletions(-)

Modified: trunk/boost/icl/concept/interval_associator.hpp
==============================================================================
--- trunk/boost/icl/concept/interval_associator.hpp (original)
+++ trunk/boost/icl/concept/interval_associator.hpp 2011-12-30 15:53:12 EST (Fri, 30 Dec 2011)
@@ -325,6 +325,7 @@
 }
 
 
+#ifdef BOOST_NO_RVALUE_REFERENCES
 //------------------------------------------------------------------------------
 //- T op + (T, c P&) T:{S}|{M} P:{e i S}|{b p M}
 //------------------------------------------------------------------------------
@@ -339,6 +340,26 @@
     return object += operand;
 }
 
+#else //BOOST_NO_RVALUE_REFERENCES
+
+template<class Type, class OperandT>
+typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
+operator + (const Type& object, const OperandT& operand)
+{
+ Type temp = object;
+ return boost::move(temp += operand);
+}
+
+template<class Type, class OperandT>
+typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
+operator + (Type&& object, const OperandT& operand)
+{
+ return boost::move(object += operand);
+}
+
+#endif //BOOST_NO_RVALUE_REFERENCES
+
+#ifdef BOOST_NO_RVALUE_REFERENCES
 //------------------------------------------------------------------------------
 //- T op + (c P&, T) T:{S}|{M} P:{e i S'}|{b p M'}
 //------------------------------------------------------------------------------
@@ -353,6 +374,26 @@
     return object += operand;
 }
 
+#else //BOOST_NO_RVALUE_REFERENCES
+
+template<class Type, class OperandT>
+typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
+operator + (const OperandT& operand, const Type& object)
+{
+ Type temp = object;
+ return boost::move(temp += operand);
+}
+
+template<class Type, class OperandT>
+typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
+operator + (const OperandT& operand, Type&& object)
+{
+ return boost::move(object += operand);
+}
+
+#endif //BOOST_NO_RVALUE_REFERENCES
+
+#ifdef BOOST_NO_RVALUE_REFERENCES
 //------------------------------------------------------------------------------
 //- T op + (T, c P&) T:{S}|{M} P:{S}|{M}
 //------------------------------------------------------------------------------
@@ -367,6 +408,38 @@
     return object += operand;
 }
 
+#else //BOOST_NO_RVALUE_REFERENCES
+
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator + (const Type& object, const Type& operand)
+{
+ Type temp = object;
+ return boost::move(temp += operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator + (Type&& object, const Type& operand)
+{
+ return boost::move(object += operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator + (const Type& operand, Type&& object)
+{
+ return boost::move(object += operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator + (Type&& object, Type&& operand)
+{
+ return boost::move(object += operand);
+}
+
+#endif //BOOST_NO_RVALUE_REFERENCES
 
 //------------------------------------------------------------------------------
 //- Addition |=, |
@@ -404,6 +477,7 @@
     return object += operand;
 }
 
+#ifdef BOOST_NO_RVALUE_REFERENCES
 //------------------------------------------------------------------------------
 //- T op | (T, c P&) T:{S}|{M} P:{e i S}|{b p M}
 //------------------------------------------------------------------------------
@@ -418,6 +492,26 @@
     return object += operand;
 }
 
+#else //BOOST_NO_RVALUE_REFERENCES
+
+template<class Type, class OperandT>
+typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
+operator | (const Type& object, const OperandT& operand)
+{
+ Type temp = object;
+ return boost::move(temp += operand);
+}
+
+template<class Type, class OperandT>
+typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
+operator | (Type&& object, const OperandT& operand)
+{
+ return boost::move(object += operand);
+}
+
+#endif //BOOST_NO_RVALUE_REFERENCES
+
+#ifdef BOOST_NO_RVALUE_REFERENCES
 //------------------------------------------------------------------------------
 //- T op | (T, c P&) T:{S}|{M} P:{S}|{M}
 //------------------------------------------------------------------------------
@@ -432,6 +526,26 @@
     return object += operand;
 }
 
+#else //BOOST_NO_RVALUE_REFERENCES
+
+template<class Type, class OperandT>
+typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
+operator | (const OperandT& operand, const Type& object)
+{
+ Type temp = object;
+ return boost::move(temp += operand);
+}
+
+template<class Type, class OperandT>
+typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
+operator | (const OperandT& operand, Type&& object)
+{
+ return boost::move(object += operand);
+}
+
+#endif //BOOST_NO_RVALUE_REFERENCES
+
+#ifdef BOOST_NO_RVALUE_REFERENCES
 //------------------------------------------------------------------------------
 //- T op | (T, c P&) T:{S}|{M} P:{S}|{M}
 //------------------------------------------------------------------------------
@@ -445,6 +559,39 @@
 {
     return object += operand;
 }
+#else //BOOST_NO_RVALUE_REFERENCES
+
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator | (const Type& object, const Type& operand)
+{
+ Type temp = object;
+ return boost::move(temp += operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator | (Type&& object, const Type& operand)
+{
+ return boost::move(object += operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator | (const Type& operand, Type&& object)
+{
+ return boost::move(object += operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator | (Type&& object, Type&& operand)
+{
+ return boost::move(object += operand);
+}
+
+#endif //BOOST_NO_RVALUE_REFERENCES
+
 
 //==============================================================================
 //= Insertion<IntervalSet|IntervalSet>
@@ -560,7 +707,7 @@
     return erase(object, operand);
 }
 
-
+#ifdef BOOST_NO_RVALUE_REFERENCES
 //------------------------------------------------------------------------------
 //- T op - (T, c P&) T:{S}|{M} P:{e i S'}|{e i b p S' M'}
 //------------------------------------------------------------------------------
@@ -571,6 +718,24 @@
     return object -= operand;
 }
 
+#else //BOOST_NO_RVALUE_REFERENCES
+
+template<class Type, class OperandT>
+typename enable_if<is_right_inter_combinable<Type, OperandT>, Type>::type
+operator - (const Type& object, const OperandT& operand)
+{
+ Type temp = object;
+ return boost::move(temp -= operand);
+}
+
+template<class Type, class OperandT>
+typename enable_if<is_right_inter_combinable<Type, OperandT>, Type>::type
+operator - (Type&& object, const OperandT& operand)
+{
+ return boost::move(object -= operand);
+}
+
+#endif //BOOST_NO_RVALUE_REFERENCES
 
 //==============================================================================
 //= Intersection<IntervalSet|IntervalSet>
@@ -611,6 +776,7 @@
     return object;
 }
 
+#ifdef BOOST_NO_RVALUE_REFERENCES
 //------------------------------------------------------------------------------
 //- T op & (T, c P&) T:{S}|{M} P:{e i S'}|{e i b p S' M'} S<S' M<M' <:coarser
 //------------------------------------------------------------------------------
@@ -621,6 +787,26 @@
     return object &= operand;
 }
 
+#else //BOOST_NO_RVALUE_REFERENCES
+
+template<class Type, class OperandT>
+typename enable_if<is_binary_inter_combinable<Type, OperandT>, Type>::type
+operator & (const Type& object, const OperandT& operand)
+{
+ Type temp = object;
+ return boost::move(temp &= operand);
+}
+
+template<class Type, class OperandT>
+typename enable_if<is_binary_inter_combinable<Type, OperandT>, Type>::type
+operator & (Type&& object, const OperandT& operand)
+{
+ return boost::move(object &= operand);
+}
+
+#endif //BOOST_NO_RVALUE_REFERENCES
+
+#ifdef BOOST_NO_RVALUE_REFERENCES
 //------------------------------------------------------------------------------
 //- T op & (c P&, T) T:{S}|{M} P:{e i S'}|{e i b p S' M'} S<S' M<M' <:coarser
 //------------------------------------------------------------------------------
@@ -631,6 +817,26 @@
     return object &= operand;
 }
 
+#else //BOOST_NO_RVALUE_REFERENCES
+
+template<class Type, class OperandT>
+typename enable_if<is_binary_inter_combinable<Type, OperandT>, Type>::type
+operator & (const OperandT& operand, const Type& object)
+{
+ Type temp = object;
+ return boost::move(temp &= operand);
+}
+
+template<class Type, class OperandT>
+typename enable_if<is_binary_inter_combinable<Type, OperandT>, Type>::type
+operator & (const OperandT& operand, Type&& object)
+{
+ return boost::move(object &= operand);
+}
+
+#endif //BOOST_NO_RVALUE_REFERENCES
+
+#ifdef BOOST_NO_RVALUE_REFERENCES
 //------------------------------------------------------------------------------
 //- T op & (T, c T&) T:{S M}
 //------------------------------------------------------------------------------
@@ -641,6 +847,39 @@
     return object &= operand;
 }
 
+#else //BOOST_NO_RVALUE_REFERENCES
+
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator & (const Type& object, const Type& operand)
+{
+ Type temp = object;
+ return boost::move(temp &= operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator & (Type&& object, const Type& operand)
+{
+ return boost::move(object &= operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator & (const Type& operand, Type&& object)
+{
+ return boost::move(object &= operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator & (Type&& object, Type&& operand)
+{
+ return boost::move(object &= operand);
+}
+
+#endif //BOOST_NO_RVALUE_REFERENCES
+
 //------------------------------------------------------------------------------
 //- intersects<IntervalSet|IntervalMap>
 //------------------------------------------------------------------------------
@@ -772,6 +1011,7 @@
     return icl::flip(object, operand);
 }
 
+#ifdef BOOST_NO_RVALUE_REFERENCES
 //------------------------------------------------------------------------------
 //- T op ^ (T, c P&) T:{S}|{M} P:{e i S'}|{b p M'} S<S' M<M' <:coarser
 //------------------------------------------------------------------------------
@@ -782,6 +1022,26 @@
     return object ^= operand;
 }
 
+#else //BOOST_NO_RVALUE_REFERENCES
+
+template<class Type, class OperandT>
+typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
+operator ^ (const Type& object, const OperandT& operand)
+{
+ Type temp = object;
+ return boost::move(temp ^= operand);
+}
+
+template<class Type, class OperandT>
+typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
+operator ^ (Type&& object, const OperandT& operand)
+{
+ return boost::move(object ^= operand);
+}
+
+#endif //BOOST_NO_RVALUE_REFERENCES
+
+#ifdef BOOST_NO_RVALUE_REFERENCES
 //------------------------------------------------------------------------------
 //- T op ^ (c P&, T) T:{S}|{M} P:{e i S'}|{b p M'} S<S' M<M' <:coarser
 //------------------------------------------------------------------------------
@@ -792,6 +1052,26 @@
     return object ^= operand;
 }
 
+#else //BOOST_NO_RVALUE_REFERENCES
+
+template<class Type, class OperandT>
+typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
+operator ^ (const OperandT& operand, const Type& object)
+{
+ Type temp = object;
+ return boost::move(temp ^= operand);
+}
+
+template<class Type, class OperandT>
+typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
+operator ^ (const OperandT& operand, Type&& object)
+{
+ return boost::move(object ^= operand);
+}
+
+#endif //BOOST_NO_RVALUE_REFERENCES
+
+#ifdef BOOST_NO_RVALUE_REFERENCES
 //------------------------------------------------------------------------------
 //- T op ^ (T, c T&) T:{S M}
 //------------------------------------------------------------------------------
@@ -802,6 +1082,39 @@
     return object ^= operand;
 }
 
+#else //BOOST_NO_RVALUE_REFERENCES
+
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator ^ (const Type& object, const Type& operand)
+{
+ Type temp = object;
+ return boost::move(temp ^= operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator ^ (Type&& object, const Type& operand)
+{
+ return boost::move(object ^= operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator ^ (const Type& operand, Type&& object)
+{
+ return boost::move(object ^= operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator ^ (Type&& object, Type&& operand)
+{
+ return boost::move(object ^= operand);
+}
+
+#endif //BOOST_NO_RVALUE_REFERENCES
+
 //==========================================================================
 //= Element Iteration <IntervalSet|IntervalMap>
 //==========================================================================

Modified: trunk/libs/icl/test/test_casual_/test_casual.cpp
==============================================================================
--- trunk/libs/icl/test/test_casual_/test_casual.cpp (original)
+++ trunk/libs/icl/test/test_casual_/test_casual.cpp 2011-12-30 15:53:12 EST (Fri, 30 Dec 2011)
@@ -39,17 +39,6 @@
 using namespace unit_test;
 using namespace boost::icl;
 
-void pass_it(shared_ptr<int> pi)
-{
- *pi = 41;
- cout << "uses: " << pi.use_count() << " cont: " << *pi << endl;
-}
-
-void pass_it_ref(shared_ptr<int>& pi)
-{
- *pi = 43;
- cout << "uses: " << pi.use_count() << " cont: " << *pi << endl;
-}
 
 BOOST_AUTO_TEST_CASE(casual)
 {
@@ -59,45 +48,10 @@
     typedef interval_set<T> IntervalSetT;
     typedef IntervalMapT::interval_type IntervalT;
 
- shared_ptr<int> pi(new int(42));
- cout << "uses: " << pi.use_count() << " cont: " << *pi << endl;
- pass_it(pi);
- pass_it_ref(pi);
-
- BOOST_CHECK_EQUAL(true, true);
-}
-
-/*
-BOOST_AUTO_TEST_CASE(isEmptyTest)
-{
- typedef int Value;
- typedef boost::icl::interval<Value> Interval;
- typedef std::numeric_limits<Value> Limits;
-
- Value const max(Limits::max());
+ IntervalSetT is = IntervalSetT(I_I(1,1)) + IntervalSetT(I_I(3,3));
 
- Interval::interval_type piff = Interval::open(max, max);
+ cout << is << endl;
 
- BOOST_CHECK(!icl::is_empty(Interval::open(max - 2, max)));
- BOOST_CHECK( icl::is_empty(Interval::open(max - 1, max)));
- BOOST_CHECK( icl::is_empty(Interval::open(max, max)));
+ BOOST_CHECK_EQUAL(true, true);
 }
-*/
-
-BOOST_AUTO_TEST_CASE(totalRangeTest)
-{
- typedef int Value;
- typedef boost::icl::interval<Value> Interval;
- typedef std::numeric_limits<Value> Limits;
- typedef boost::icl::interval_map<Value, int, boost::icl::total_enricher> Container;
 
- Value const min(Limits::min());
- Value const max(Limits::max());
-
- boost::icl::interval_map<Value, int, boost::icl::total_enricher> intervals;
-
- intervals += std::make_pair(Interval::closed(min, max), 0);
- intervals += std::make_pair(Interval::right_open(0, 10), 3);
-
- BOOST_CHECK_EQUAL(intervals.iterative_size(), 3);
-}

Modified: trunk/libs/icl/test/vc10_icl_fast_tests.sln
==============================================================================
--- trunk/libs/icl/test/vc10_icl_fast_tests.sln (original)
+++ trunk/libs/icl/test/vc10_icl_fast_tests.sln 2011-12-30 15:53:12 EST (Fri, 30 Dec 2011)
@@ -65,6 +65,8 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc10_test_type_traits", "test_type_traits_\vc10_test_type_traits.vcxproj", "{EE61B7EF-EC45-4165-8B59-FD5B8D6A9FA0}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc10_test_casual", "test_casual_\vc10_test_casual.vcxproj", "{EE61B7EF-EC45-4165-8B59-FD5B8D3A9FA0}"
+EndProject
 Global
         GlobalSection(SolutionConfigurationPlatforms) = preSolution
                 Debug|Win32 = Debug|Win32
@@ -199,6 +201,10 @@
                 {EE61B7EF-EC45-4165-8B59-FD5B8D6A9FA0}.Debug|Win32.Build.0 = Debug|Win32
                 {EE61B7EF-EC45-4165-8B59-FD5B8D6A9FA0}.Release|Win32.ActiveCfg = Release|Win32
                 {EE61B7EF-EC45-4165-8B59-FD5B8D6A9FA0}.Release|Win32.Build.0 = Release|Win32
+ {EE61B7EF-EC45-4165-8B59-FD5B8D3A9FA0}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EE61B7EF-EC45-4165-8B59-FD5B8D3A9FA0}.Debug|Win32.Build.0 = Debug|Win32
+ {EE61B7EF-EC45-4165-8B59-FD5B8D3A9FA0}.Release|Win32.ActiveCfg = Release|Win32
+ {EE61B7EF-EC45-4165-8B59-FD5B8D3A9FA0}.Release|Win32.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(SolutionProperties) = preSolution
                 HideSolutionNode = FALSE


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