Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83706 - in trunk/boost/geometry/index: . detail
From: adam.wulkiewicz_at_[hidden]
Date: 2013-04-01 22:35:04


Author: awulkiew
Date: 2013-04-01 22:35:03 EDT (Mon, 01 Apr 2013)
New Revision: 83706
URL: http://svn.boost.org/trac/boost/changeset/83706

Log:
rtree: added allocator propagation test in swap()
Added:
   trunk/boost/geometry/index/detail/utilities.hpp (contents, props changed)
Text files modified:
   trunk/boost/geometry/index/rtree.hpp | 23 ++++++++---------------
   1 files changed, 8 insertions(+), 15 deletions(-)

Added: trunk/boost/geometry/index/detail/utilities.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/geometry/index/detail/utilities.hpp 2013-04-01 22:35:03 EDT (Mon, 01 Apr 2013)
@@ -0,0 +1,69 @@
+// Boost.Geometry Index
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/swap.hpp>
+//#include <boost/type_traits/is_empty.hpp>
+
+#ifndef BOOST_GEOMETRY_INDEX_DETAIL_UTILITIES_HPP
+#define BOOST_GEOMETRY_INDEX_DETAIL_UTILITIES_HPP
+
+namespace boost { namespace geometry { namespace index { namespace detail {
+
+template<class T>
+static inline void assign_cond(T & l, T const& r, boost::mpl::bool_<true> const&)
+{
+ l = r;
+}
+
+template<class T>
+static inline void assign_cond(T &, T const&, boost::mpl::bool_<false> const&) {}
+
+template<class T>
+static inline void move_cond(T & l, T & r, boost::mpl::bool_<true> const&)
+{
+ l = ::boost::move(r);
+}
+
+template<class T>
+static inline void move_cond(T &, T &, boost::mpl::bool_<false> const&) {}
+
+// Darwin compiler (tested on 4.2.1) can't copy empty base classes properly!
+// Consider using following functions:
+
+//template <typename T> inline
+//void swap_cond_impl(T &, T &, boost::true_type const& /*is_empty*/) {}
+//
+//template <typename T> inline
+//void swap_cond_impl(T & l, T & r, boost::false_type const& /*is_empty*/)
+//{
+// ::boost::swap(l, r);
+//}
+//
+//template <typename T> inline
+//void swap_cond(T & l, T & r, boost::mpl::bool_<true> const&)
+//{
+//#ifdef BOOST_IS_EMPTY
+// typedef typename ::boost::is_empty<T>::type is_empty;
+//#else
+// typedef ::boost::false_type is_empty;
+//#endif
+// swap_cond_impl(l, r, is_empty());
+//}
+
+template <typename T> inline
+void swap_cond(T & l, T & r, boost::mpl::bool_<true> const&)
+{
+ ::boost::swap(l, r);
+}
+
+template <typename T> inline
+void swap_cond(T & l, T & r, boost::mpl::bool_<false> const&) {}
+
+}}}} // namespace boost::geometry::index::detail
+
+#endif // BOOST_GEOMETRY_INDEX_DETAIL_UTILITIES_HPP

Modified: trunk/boost/geometry/index/rtree.hpp
==============================================================================
--- trunk/boost/geometry/index/rtree.hpp (original)
+++ trunk/boost/geometry/index/rtree.hpp 2013-04-01 22:35:03 EDT (Mon, 01 Apr 2013)
@@ -35,6 +35,7 @@
 #include <boost/geometry/index/distance_predicates.hpp>
 #include <boost/geometry/index/detail/rtree/adaptors.hpp>
 
+#include <boost/geometry/index/detail/utilities.hpp>
 #include <boost/geometry/index/detail/rtree/node/node.hpp>
 
 #include <boost/geometry/index/detail/algorithms/is_valid.hpp>
@@ -387,7 +388,7 @@
> propagate;
             if ( propagate::value && !(this_allocs == src_allocs) )
                 this->raw_destroy(*this);
- assign_cond(this_allocs, src_allocs, propagate());
+ detail::assign_cond(this_allocs, src_allocs, propagate());
 
             // It uses m_allocators
             this->raw_copy(src, *this, true);
@@ -431,7 +432,7 @@
                 typedef boost::mpl::bool_<
                     allocator_traits_type::propagate_on_container_move_assignment::value
> propagate;
- rtree::move_cond(this_allocs, src_allocs, propagate());
+ detail::move_cond(this_allocs, src_allocs, propagate());
             }
             else
             {
@@ -460,7 +461,11 @@
         boost::swap(m_members.indexable_getter(), other.m_members.indexable_getter());
         boost::swap(m_members.equal_to(), other.m_members.equal_to());
         boost::swap(m_members.parameters(), other.m_members.parameters());
- m_members.allocators().swap(other.m_members.allocators());
+
+ typedef boost::mpl::bool_<
+ allocator_traits_type::propagate_on_container_swap::value
+ > propagate;
+ detail::swap_cond(m_members.allocators(), other.m_members.allocators(), propagate());
 
         boost::swap(m_members.values_count, other.m_members.values_count);
         boost::swap(m_members.leafs_level, other.m_members.leafs_level);
@@ -1123,18 +1128,6 @@
         return result.finish();
     }
 
- template<class T>
- static inline void assign_cond(T &, T const&, boost::mpl::bool_<false> const&) {}
-
- template<class T>
- static inline void assign_cond(T & l, T const& r, boost::mpl::bool_<true> const&) { l = r; }
-
- template<class T>
- static inline void move_cond(T &, T &, boost::mpl::bool_<false> const&) {}
-
- template<class T>
- static inline void move_cond(T & l, T & r, boost::mpl::bool_<true> const&) { l = ::boost::move(r); }
-
     struct members_holder
         : public translator_type
         , public Parameters


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