Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85210 - trunk/boost/geometry/index/detail
From: adam.wulkiewicz_at_[hidden]
Date: 2013-08-04 17:37:45


Author: awulkiew
Date: 2013-08-04 17:37:45 EDT (Sun, 04 Aug 2013)
New Revision: 85210
URL: http://svn.boost.org/trac/boost/changeset/85210

Log:
[geometry][index] varray elements move construction and assignment dispatched using has_trivial_move_xxx, clang ambiguity fixed

Text files modified:
   trunk/boost/geometry/index/detail/varray.hpp | 1
   trunk/boost/geometry/index/detail/varray_detail.hpp | 74 +++++++++++++++++++++++++++++++--------
   2 files changed, 59 insertions(+), 16 deletions(-)

Modified: trunk/boost/geometry/index/detail/varray.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/varray.hpp Sun Aug 4 10:45:37 2013 (r85209)
+++ trunk/boost/geometry/index/detail/varray.hpp 2013-08-04 17:37:45 EDT (Sun, 04 Aug 2013) (r85210)
@@ -37,6 +37,7 @@
 #include <boost/geometry/index/detail/varray_detail.hpp>
 
 #include <boost/concept_check.hpp>
+#include <boost/throw_exception.hpp>
 
 /*!
 \defgroup varray_non_member varray non-member functions

Modified: trunk/boost/geometry/index/detail/varray_detail.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/varray_detail.hpp Sun Aug 4 10:45:37 2013 (r85209)
+++ trunk/boost/geometry/index/detail/varray_detail.hpp 2013-08-04 17:37:45 EDT (Sun, 04 Aug 2013) (r85210)
@@ -29,6 +29,8 @@
 #include <boost/type_traits/has_trivial_copy.hpp>
 #include <boost/type_traits/has_trivial_constructor.hpp>
 #include <boost/type_traits/has_trivial_destructor.hpp>
+#include <boost/type_traits/has_trivial_move_constructor.hpp>
+#include <boost/type_traits/has_trivial_move_assign.hpp>
 //#include <boost/type_traits/has_nothrow_constructor.hpp>
 //#include <boost/type_traits/has_nothrow_copy.hpp>
 //#include <boost/type_traits/has_nothrow_assign.hpp>
@@ -409,12 +411,12 @@
 template <typename I, typename O>
 inline
 O uninitialized_move_if_noexcept_dispatch(I first, I last, O dst, boost::mpl::bool_<true> const& /*use_move*/)
-{ return uninitialized_move(first, last, dst); }
+{ return varray_detail::uninitialized_move(first, last, dst); }
 
 template <typename I, typename O>
 inline
 O uninitialized_move_if_noexcept_dispatch(I first, I last, O dst, boost::mpl::bool_<false> const& /*use_move*/)
-{ return uninitialized_copy(first, last, dst); }
+{ return varray_detail::uninitialized_copy(first, last, dst); }
 
 template <typename I, typename O>
 inline
@@ -532,16 +534,16 @@
 
 template <typename I, typename V>
 inline
-void construct_dispatch(I pos, V const& v,
- boost::mpl::bool_<true> const& /*use_memcpy*/)
+void construct_copy_dispatch(I pos, V const& v,
+ boost::mpl::bool_<true> const& /*use_memcpy*/)
 {
     ::memcpy(boost::addressof(*pos), boost::addressof(v), sizeof(V));
 }
 
 template <typename I, typename P>
 inline
-void construct_dispatch(I pos, P const& p,
- boost::mpl::bool_<false> const& /*use_memcpy*/)
+void construct_copy_dispatch(I pos, P const& p,
+ boost::mpl::bool_<false> const& /*use_memcpy*/)
 {
     typedef typename boost::iterator_value<I>::type V;
     new (static_cast<void*>(boost::addressof(*pos))) V(p); // may throw
@@ -559,11 +561,28 @@
>::type
     use_memcpy;
 
- construct_dispatch(pos, p, use_memcpy()); // may throw
+ construct_copy_dispatch(pos, p, use_memcpy()); // may throw
 }
 
 // Needed by push_back(V &&)
 
+template <typename I, typename V>
+inline
+void construct_move_dispatch(I pos, V const& v,
+ boost::mpl::bool_<true> const& /*use_memcpy*/)
+{
+ ::memcpy(boost::addressof(*pos), boost::addressof(v), sizeof(V));
+}
+
+template <typename I, typename P>
+inline
+void construct_move_dispatch(I pos, BOOST_RV_REF(P) p,
+ boost::mpl::bool_<false> const& /*use_memcpy*/)
+{
+ typedef typename boost::iterator_value<I>::type V;
+ new (static_cast<void*>(boost::addressof(*pos))) V(::boost::move(p)); // may throw
+}
+
 template <typename DisableTrivialInit, typename I, typename P>
 inline
 void construct(DisableTrivialInit const&, I pos, BOOST_RV_REF(P) p)
@@ -571,12 +590,11 @@
     typedef typename
     ::boost::mpl::and_<
         is_corresponding_value<I, P>,
- ::boost::has_trivial_copy<P>
+ ::boost::has_trivial_move_constructor<P>
>::type
     use_memcpy;
 
- typedef typename boost::iterator_value<I>::type V;
- new (static_cast<void*>(boost::addressof(*pos))) V(::boost::move(p)); // may throw
+ construct_move_dispatch(pos, ::boost::move(p), use_memcpy()); // may throw
 }
 
 // Needed by emplace_back() and emplace()
@@ -624,16 +642,17 @@
 
 template <typename I, typename V>
 inline
-void assign_dispatch(I pos, V const& v,
- boost::mpl::bool_<true> const& /*use_memcpy*/)
+void assign_copy_dispatch(I pos, V const& v,
+ boost::mpl::bool_<true> const& /*use_memcpy*/)
 {
+// TODO - use memmove here?
     ::memcpy(boost::addressof(*pos), boost::addressof(v), sizeof(V));
 }
 
 template <typename I, typename V>
 inline
-void assign_dispatch(I pos, V const& v,
- boost::mpl::bool_<false> const& /*use_memcpy*/)
+void assign_copy_dispatch(I pos, V const& v,
+ boost::mpl::bool_<false> const& /*use_memcpy*/)
 {
     *pos = v; // may throw
 }
@@ -649,16 +668,39 @@
>::type
     use_memcpy;
 
- assign_dispatch(pos, v, use_memcpy()); // may throw
+ assign_copy_dispatch(pos, v, use_memcpy()); // may throw
 }
 
 template <typename I, typename V>
 inline
-void assign(I pos, BOOST_RV_REF(V) v)
+void assign_move_dispatch(I pos, V const& v,
+ boost::mpl::bool_<true> const& /*use_memcpy*/)
+{
+// TODO - use memmove here?
+ ::memcpy(boost::addressof(*pos), boost::addressof(v), sizeof(V));
+}
+
+template <typename I, typename V>
+inline
+void assign_move_dispatch(I pos, BOOST_RV_REF(V) v,
+ boost::mpl::bool_<false> const& /*use_memcpy*/)
 {
     *pos = boost::move(v); // may throw
 }
 
+template <typename I, typename V>
+inline
+void assign(I pos, BOOST_RV_REF(V) v)
+{
+ typedef typename
+ ::boost::mpl::and_<
+ is_corresponding_value<I, V>,
+ ::boost::has_trivial_move_assign<V>
+ >::type
+ use_memcpy;
+
+ assign_move_dispatch(pos, ::boost::move(v), use_memcpy());
+}
 
 // uninitialized_copy_s
 


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