Boost logo

Boost-Commit :

From: joaquin_at_[hidden]
Date: 2007-11-26 08:48:36


Author: joaquin
Date: 2007-11-26 08:48:36 EST (Mon, 26 Nov 2007)
New Revision: 41397
URL: http://svn.boost.org/trac/boost/changeset/41397

Log:
ADL-based swap call moved to an utility function (after mistaken attempt at rev 41220 to solve name-hiding issues)
Added:
   trunk/boost/multi_index/detail/adl_swap.hpp (contents, props changed)
Text files modified:
   trunk/boost/multi_index/detail/auto_space.hpp | 25 +++++--------------------
   trunk/boost/multi_index_container.hpp | 10 ++--------
   2 files changed, 7 insertions(+), 28 deletions(-)

Added: trunk/boost/multi_index/detail/adl_swap.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/multi_index/detail/adl_swap.hpp 2007-11-26 08:48:36 EST (Mon, 26 Nov 2007)
@@ -0,0 +1,44 @@
+/* Copyright 2003-2007 Joaquín M López Muñoz.
+ * Distributed under 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)
+ *
+ * See http://www.boost.org/libs/multi_index for library home page.
+ */
+
+#ifndef BOOST_MULTI_INDEX_DETAIL_ADL_SWAP_HPP
+#define BOOST_MULTI_INDEX_DETAIL_ADL_SWAP_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <algorithm>
+
+namespace boost{
+
+namespace multi_index{
+
+namespace detail{
+
+template<typename T>
+void adl_swap(T& x,T& y)
+{
+
+#if !defined(BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL)
+ using std::swap;
+ swap(x,y);
+#else
+ std::swap(x,y);
+#endif
+
+}
+
+} /* namespace multi_index::detail */
+
+} /* namespace multi_index */
+
+} /* namespace boost */
+
+#endif

Modified: trunk/boost/multi_index/detail/auto_space.hpp
==============================================================================
--- trunk/boost/multi_index/detail/auto_space.hpp (original)
+++ trunk/boost/multi_index/detail/auto_space.hpp 2007-11-26 08:48:36 EST (Mon, 26 Nov 2007)
@@ -16,6 +16,7 @@
 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
 #include <algorithm>
 #include <boost/detail/allocator_utilities.hpp>
+#include <boost/multi_index/detail/adl_swap.hpp>
 #include <boost/multi_index/detail/prevent_eti.hpp>
 #include <boost/noncopyable.hpp>
 #include <memory>
@@ -65,30 +66,14 @@
 
   pointer data()const{return data_;}
 
- void swap(auto_space& x){swap_(x);}
-
-private:
- void swap_(auto_space& x)
+ void swap(auto_space& x)
   {
- /* Swapping is done inside swap_() rather than swap() so as to avoid
- * name hiding when ADLing swap below. Not sure if this is legally
- * required, though.
- */
-
- if(al_!=x.al_){
-
-#if defined(BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL)
- std::swap(al_,x.al_);
-#else
- using std::swap;
- swap(al_,x.al_);
-#endif
-
- }
+ if(al_!=x.al_)adl_swap(al_,x.al_);
     std::swap(n_,x.n_);
     std::swap(data_,x.data_);
   }
-
+
+private:
   typename boost::detail::allocator::rebind_to<
     Allocator,T>::type al_;
   std::size_t n_;

Modified: trunk/boost/multi_index_container.hpp
==============================================================================
--- trunk/boost/multi_index_container.hpp (original)
+++ trunk/boost/multi_index_container.hpp 2007-11-26 08:48:36 EST (Mon, 26 Nov 2007)
@@ -29,6 +29,7 @@
 #include <boost/mpl/deref.hpp>
 #include <boost/multi_index_container_fwd.hpp>
 #include <boost/multi_index/detail/access_specifier.hpp>
+#include <boost/multi_index/detail/adl_swap.hpp>
 #include <boost/multi_index/detail/base_type.hpp>
 #include <boost/multi_index/detail/converter.hpp>
 #include <boost/multi_index/detail/header_holder.hpp>
@@ -540,14 +541,7 @@
   void swap_(multi_index_container<Value,IndexSpecifierList,Allocator>& x)
   {
     if(bfm_allocator::member!=x.bfm_allocator::member){
-
-#if defined(BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL)
- std::swap(bfm_allocator::member,x.bfm_allocator::member);
-#else
- using std::swap;
- swap(bfm_allocator::member,x.bfm_allocator::member);
-#endif
-
+ detail::adl_swap(bfm_allocator::member,x.bfm_allocator::member);
     }
     std::swap(bfm_header::member,x.bfm_header::member);
     super::swap_(x);


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