|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r83383 - trunk/boost/icl
From: afojgo_at_[hidden]
Date: 2013-03-09 18:24:17
Author: jofaber
Date: 2013-03-09 18:24:16 EST (Sat, 09 Mar 2013)
New Revision: 83383
URL: http://svn.boost.org/trac/boost/changeset/83383
Log:
Simplifying operator = implementations with move using call by value ("sink arguments").
Text files modified:
trunk/boost/icl/impl_config.hpp | 8 ++++----
trunk/boost/icl/interval_base_map.hpp | 20 +++++++++++---------
trunk/boost/icl/interval_base_set.hpp | 20 +++++++++++---------
trunk/boost/icl/interval_map.hpp | 35 ++++++++++++++++++++---------------
trunk/boost/icl/interval_set.hpp | 37 +++++++++++++++++++------------------
trunk/boost/icl/map.hpp | 18 ++++++++++--------
trunk/boost/icl/separate_interval_set.hpp | 30 ++++++++++++++++--------------
trunk/boost/icl/split_interval_map.hpp | 35 ++++++++++++++++++++---------------
trunk/boost/icl/split_interval_set.hpp | 32 ++++++++++++++++++--------------
9 files changed, 129 insertions(+), 106 deletions(-)
Modified: trunk/boost/icl/impl_config.hpp
==============================================================================
--- trunk/boost/icl/impl_config.hpp (original)
+++ trunk/boost/icl/impl_config.hpp 2013-03-09 18:24:16 EST (Sat, 09 Mar 2013)
@@ -48,10 +48,10 @@
+-----------------------------------------------------------------------------*/
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
# define BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
-#elif defined(__clang__)
-# define BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
-#elif (defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))
-# define BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
+//#elif defined(__clang__)
+//# define BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
+//#elif (defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))
+//# define BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
#endif
#include <boost/move/move.hpp>
Modified: trunk/boost/icl/interval_base_map.hpp
==============================================================================
--- trunk/boost/icl/interval_base_map.hpp (original)
+++ trunk/boost/icl/interval_base_map.hpp 2013-03-09 18:24:16 EST (Sat, 09 Mar 2013)
@@ -215,13 +215,6 @@
BOOST_CONCEPT_ASSERT((EqualComparableConcept<CodomainT>));
}
- /** Copy assignment operator */
- interval_base_map& operator = (const interval_base_map& src)
- {
- this->_map = src._map;
- return *this;
- }
-
# ifndef BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
//==========================================================================
//= Move semantics
@@ -237,13 +230,22 @@
}
/** Move assignment operator */
- interval_base_map& operator = (interval_base_map&& src)
- {
+ interval_base_map& operator = (interval_base_map src)
+ { //call by value sice 'src' is a "sink value"
this->_map = boost::move(src._map);
return *this;
}
//==========================================================================
+# else
+
+ /** Copy assignment operator */
+ interval_base_map& operator = (const interval_base_map& src)
+ {
+ this->_map = src._map;
+ return *this;
+ }
+
# endif // BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
/** swap the content of containers */
Modified: trunk/boost/icl/interval_base_set.hpp
==============================================================================
--- trunk/boost/icl/interval_base_set.hpp (original)
+++ trunk/boost/icl/interval_base_set.hpp 2013-03-09 18:24:16 EST (Sat, 09 Mar 2013)
@@ -168,13 +168,6 @@
BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
}
- /** Assignment operator */
- interval_base_set& operator = (const interval_base_set& src)
- {
- this->_set = src._set;
- return *this;
- }
-
# ifndef BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
//==========================================================================
//= Move semantics
@@ -188,13 +181,22 @@
}
/** Move assignment operator */
- interval_base_set& operator = (interval_base_set&& src)
- {
+ interval_base_set& operator = (interval_base_set src)
+ { //call by value sice 'src' is a "sink value"
this->_set = boost::move(src._set);
return *this;
}
//==========================================================================
+# else
+
+ /** Copy assignment operator */
+ interval_base_set& operator = (const interval_base_set& src)
+ {
+ this->_set = src._set;
+ return *this;
+ }
+
# endif // BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
/** swap the content of containers */
Modified: trunk/boost/icl/interval_map.hpp
==============================================================================
--- trunk/boost/icl/interval_map.hpp (original)
+++ trunk/boost/icl/interval_map.hpp 2013-03-09 18:24:16 EST (Sat, 09 Mar 2013)
@@ -93,20 +93,6 @@
{ this->add(value_pair); }
- /// Assignment operator
- interval_map& operator = (const interval_map& src)
- {
- base_type::operator=(src);
- return *this;
- }
-
- /// Assignment operator for base type
- template<class SubType>
- interval_map& operator =
- (const interval_base_map<SubType,DomainT,CodomainT,
- Traits,Compare,Combine,Section,Interval,Alloc>& src)
- { this->assign(src); return *this; }
-
/// Assignment from a base interval_map.
template<class SubType>
void assign(const interval_base_map<SubType,DomainT,CodomainT,
@@ -120,6 +106,16 @@
prior_ = this->add(prior_, *it_);
}
+ /// Assignment operator for base type
+ template<class SubType>
+ interval_map& operator =
+ (const interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc>& src)
+ {
+ this->assign(src);
+ return *this;
+ }
+
# ifndef BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
//==========================================================================
//= Move semantics
@@ -131,13 +127,22 @@
{}
/// Move assignment operator
- interval_map& operator = (interval_map&& src)
+ interval_map& operator = (interval_map src)
{
base_type::operator=(boost::move(src));
return *this;
}
//==========================================================================
+# else
+
+ /// Assignment operator
+ interval_map& operator = (const interval_map& src)
+ {
+ base_type::operator=(src);
+ return *this;
+ }
+
# endif // BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
private:
Modified: trunk/boost/icl/interval_set.hpp
==============================================================================
--- trunk/boost/icl/interval_set.hpp (original)
+++ trunk/boost/icl/interval_set.hpp 2013-03-09 18:24:16 EST (Sat, 09 Mar 2013)
@@ -115,23 +115,6 @@
this->add(itv);
}
- /// Assignment operator
- interval_set& operator = (const interval_set& src)
- {
- base_type::operator=(src);
- return *this;
- }
-
- /// Assignment operator for base type
- template<class SubType>
- interval_set& operator =
- (const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
- {
- this->assign(src);
- return *this;
- }
-
-
/// Assignment from a base interval_set.
template<class SubType>
void assign(const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
@@ -144,6 +127,15 @@
prior_ = this->add(prior_, *it_);
}
+ /// Assignment operator for base type
+ template<class SubType>
+ interval_set& operator =
+ (const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
+ {
+ this->assign(src);
+ return *this;
+ }
+
# ifndef BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
//==========================================================================
//= Move semantics
@@ -155,12 +147,21 @@
{}
/// Move assignment operator
- interval_set& operator = (interval_set&& src)
+ interval_set& operator = (interval_set src)
{
base_type::operator=(boost::move(src));
return *this;
}
+
//==========================================================================
+# else
+ /// Assignment operator
+ interval_set& operator = (const interval_set& src)
+ {
+ base_type::operator=(src);
+ return *this;
+ }
+
# endif // BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
private:
Modified: trunk/boost/icl/map.hpp
==============================================================================
--- trunk/boost/icl/map.hpp (original)
+++ trunk/boost/icl/map.hpp 2013-03-09 18:24:16 EST (Sat, 09 Mar 2013)
@@ -192,12 +192,6 @@
insert(key_value_pair);
}
- map& operator = (const map& src)
- {
- base_type::operator=(src);
- return *this;
- }
-
# ifndef BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
//==========================================================================
//= Move semantics
@@ -212,12 +206,20 @@
BOOST_CONCEPT_ASSERT((EqualComparableConcept<CodomainT>));
}
- map& operator = (map&& src)
+ map& operator = (map src)
{
- base_type::operator=(src);
+ base_type::operator=(boost::move(src));
return *this;
}
//==========================================================================
+# else
+
+ map& operator = (const map& src)
+ {
+ base_type::operator=(src);
+ return *this;
+ }
+
# endif // BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
void swap(map& src) { base_type::swap(src); }
Modified: trunk/boost/icl/separate_interval_set.hpp
==============================================================================
--- trunk/boost/icl/separate_interval_set.hpp (original)
+++ trunk/boost/icl/separate_interval_set.hpp 2013-03-09 18:24:16 EST (Sat, 09 Mar 2013)
@@ -106,11 +106,12 @@
/// Constructor for a single interval
explicit separate_interval_set(const interval_type& itv): base_type() { this->add(itv); }
- /// Assignment operator
- separate_interval_set& operator = (const separate_interval_set& src)
- {
- base_type::operator=(src);
- return *this;
+ /// Assignment from a base interval_set.
+ template<class SubType>
+ void assign(const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
+ {
+ this->clear();
+ this->_set.insert(src.begin(), src.end());
}
/// Assignment operator for base type
@@ -122,14 +123,6 @@
return *this;
}
- /// Assignment from a base interval_set.
- template<class SubType>
- void assign(const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
- {
- this->clear();
- this->_set.insert(src.begin(), src.end());
- }
-
# ifndef BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
//==========================================================================
//= Move semantics
@@ -141,12 +134,21 @@
{}
/// Move assignment operator
- separate_interval_set& operator = (separate_interval_set&& src)
+ separate_interval_set& operator = (separate_interval_set src)
{
base_type::operator=(boost::move(src));
return *this;
}
//==========================================================================
+# else
+
+ /// Assignment operator
+ separate_interval_set& operator = (const separate_interval_set& src)
+ {
+ base_type::operator=(src);
+ return *this;
+ }
+
# endif // BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
private:
Modified: trunk/boost/icl/split_interval_map.hpp
==============================================================================
--- trunk/boost/icl/split_interval_map.hpp (original)
+++ trunk/boost/icl/split_interval_map.hpp 2013-03-09 18:24:16 EST (Sat, 09 Mar 2013)
@@ -78,20 +78,6 @@
explicit split_interval_map(const value_type& value_pair): base_type()
{ this->add(value_pair); }
- /// Assignment operator
- split_interval_map& operator = (const split_interval_map& src)
- {
- base_type::operator=(src);
- return *this;
- }
-
- /// Assignment operator for base type
- template<class SubType>
- split_interval_map& operator =
- (const interval_base_map<SubType,DomainT,CodomainT,
- Traits,Compare,Combine,Section,Interval,Alloc>& src)
- { this->assign(src); return *this; }
-
/// Assignment from a base interval_map.
template<class SubType>
void assign(const interval_base_map<SubType,DomainT,CodomainT,
@@ -101,6 +87,16 @@
this->_map.insert(src.begin(), src.end());
}
+ /// Assignment operator for base type
+ template<class SubType>
+ split_interval_map& operator =
+ (const interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc>& src)
+ {
+ this->assign(src);
+ return *this;
+ }
+
# ifndef BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
//==========================================================================
//= Move semantics
@@ -112,13 +108,22 @@
{}
/// Move assignment operator
- split_interval_map& operator = (split_interval_map&& src)
+ split_interval_map& operator = (split_interval_map src)
{
base_type::operator=(boost::move(src));
return *this;
}
//==========================================================================
+# else
+
+ /// Assignment operator
+ split_interval_map& operator = (const split_interval_map& src)
+ {
+ base_type::operator=(src);
+ return *this;
+ }
+
# endif // BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
private:
Modified: trunk/boost/icl/split_interval_set.hpp
==============================================================================
--- trunk/boost/icl/split_interval_set.hpp (original)
+++ trunk/boost/icl/split_interval_set.hpp 2013-03-09 18:24:16 EST (Sat, 09 Mar 2013)
@@ -104,19 +104,6 @@
/// Constructor for a single interval
explicit split_interval_set(const domain_type& itv): base_type() { this->add(itv); }
- /// Assignment operator
- split_interval_set& operator = (const split_interval_set& src)
- {
- base_type::operator=(src);
- return *this;
- }
-
- /// Assignment operator for base type
- template<class SubType>
- split_interval_set& operator =
- (const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
- { this->assign(src); return *this; }
-
/// Assignment from a base interval_set.
template<class SubType>
void assign(const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
@@ -125,6 +112,15 @@
this->_set.insert(src.begin(), src.end());
}
+ /// Assignment operator for base type
+ template<class SubType>
+ split_interval_set& operator =
+ (const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
+ {
+ this->assign(src);
+ return *this;
+ }
+
# ifndef BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
//==========================================================================
//= Move semantics
@@ -142,8 +138,16 @@
return *this;
}
//==========================================================================
-# endif // BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
+# else
+
+ /// Assignment operator
+ split_interval_set& operator = (const split_interval_set& src)
+ {
+ base_type::operator=(src);
+ return *this;
+ }
+# endif // BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
private:
// Private functions that shall be accessible by the baseclass:
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