Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52396 - in sandbox/move/boost/unordered: . detail
From: daniel_james_at_[hidden]
Date: 2009-04-14 13:49:07


Author: danieljames
Date: 2009-04-14 13:49:06 EDT (Tue, 14 Apr 2009)
New Revision: 52396
URL: http://svn.boost.org/trac/boost/changeset/52396

Log:
Convert Boost.Unordered to use the new move library.
Removed:
   sandbox/move/boost/unordered/detail/move.hpp
Text files modified:
   sandbox/move/boost/unordered/unordered_map.hpp | 41 ++++++++++++++-------------------------
   sandbox/move/boost/unordered/unordered_set.hpp | 39 ++++++++++++-------------------------
   2 files changed, 28 insertions(+), 52 deletions(-)

Deleted: sandbox/move/boost/unordered/detail/move.hpp
==============================================================================
--- sandbox/move/boost/unordered/detail/move.hpp 2009-04-14 13:49:06 EDT (Tue, 14 Apr 2009)
+++ (empty file)
@@ -1,228 +0,0 @@
-/*
- Copyright 2005-2007 Adobe Systems Incorporated
-
- Use, modification and distribution are 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).
-*/
-
-/*************************************************************************************************/
-
-#ifndef BOOST_UNORDERED_DETAIL_MOVE_HEADER
-#define BOOST_UNORDERED_DETAIL_MOVE_HEADER
-
-
-#include <boost/mpl/bool.hpp>
-#include <boost/mpl/and.hpp>
-#include <boost/mpl/or.hpp>
-#include <boost/mpl/not.hpp>
-#include <boost/type_traits/is_convertible.hpp>
-#include <boost/type_traits/is_same.hpp>
-#include <boost/type_traits/is_class.hpp>
-#include <boost/utility/enable_if.hpp>
-#include <boost/unordered/detail/config.hpp>
-
-/*************************************************************************************************/
-
-namespace boost {
-namespace unordered_detail {
-
-/*************************************************************************************************/
-
-namespace move_detail {
-
-/*************************************************************************************************/
-
-#if !defined(BOOST_UNORDERED_NO_HAS_MOVE_ASSIGN)
-
-/*************************************************************************************************/
-
-template <typename T>
-struct class_has_move_assign {
- class type {
- typedef T& (T::*E)(T t);
- typedef char (&no_type)[1];
- typedef char (&yes_type)[2];
- template <E e> struct sfinae { typedef yes_type type; };
- template <class U>
- static typename sfinae<&U::operator=>::type test(int);
- template <class U>
- static no_type test(...);
- public:
- enum {value = sizeof(test<T>(1)) == sizeof(yes_type)};
- };
- };
-
-/*************************************************************************************************/
-
-template<typename T>
-struct has_move_assign : boost::mpl::and_<boost::is_class<T>, class_has_move_assign<T> > {};
-
-/*************************************************************************************************/
-
-class test_can_convert_anything { };
-
-/*************************************************************************************************/
-
-#endif // BOOST_UNORDERED_NO_HAS_MOVE_ASSIGN
-
-/*************************************************************************************************/
-
-/*
- REVISIT (sparent_at_[hidden]): This is a work around for Boost 1.34.1 and VC++ 2008 where
- boost::is_convertible<T, T> fails to compile.
-*/
-
-template <typename T, typename U>
-struct is_convertible : boost::mpl::or_<
- boost::is_same<T, U>,
- boost::is_convertible<T, U>
-> { };
-
-/*************************************************************************************************/
-
-} //namespace move_detail
-
-
-/*************************************************************************************************/
-
-/*!
-\ingroup move_related
-\brief move_from is used for move_ctors.
-*/
-
-template <typename T>
-struct move_from
-{
- explicit move_from(T& x) : source(x) { }
- T& source;
-};
-
-/*************************************************************************************************/
-
-#if !defined(BOOST_UNORDERED_NO_HAS_MOVE_ASSIGN)
-
-/*************************************************************************************************/
-
-/*!
-\ingroup move_related
-\brief The is_movable trait can be used to identify movable types.
-*/
-template <typename T>
-struct is_movable : boost::mpl::and_<
- boost::is_convertible<move_from<T>, T>,
- move_detail::has_move_assign<T>,
- boost::mpl::not_<boost::is_convertible<move_detail::test_can_convert_anything, T> >
- > { };
-
-/*************************************************************************************************/
-
-#else // BOOST_UNORDERED_NO_HAS_MOVE_ASSIGN
-
-// On compilers which don't have adequate SFINAE support, treat most types as unmovable,
-// unless the trait is specialized.
-
-template <typename T>
-struct is_movable : boost::mpl::false_ { };
-
-#endif
-
-/*************************************************************************************************/
-
-#if !defined(BOOST_NO_SFINAE)
-
-/*************************************************************************************************/
-
-/*!
-\ingroup move_related
-\brief copy_sink and move_sink are used to select between overloaded operations according to
- whether type T is movable and convertible to type U.
-\sa move
-*/
-
-template <typename T,
- typename U = T,
- typename R = void*>
-struct copy_sink : boost::enable_if<
- boost::mpl::and_<
- boost::unordered_detail::move_detail::is_convertible<T, U>,
- boost::mpl::not_<is_movable<T> >
- >,
- R
- >
-{ };
-
-/*************************************************************************************************/
-
-/*!
-\ingroup move_related
-\brief move_sink and copy_sink are used to select between overloaded operations according to
- whether type T is movable and convertible to type U.
- \sa move
-*/
-
-template <typename T,
- typename U = T,
- typename R = void*>
-struct move_sink : boost::enable_if<
- boost::mpl::and_<
- boost::unordered_detail::move_detail::is_convertible<T, U>,
- is_movable<T>
- >,
- R
- >
-{ };
-
-/*************************************************************************************************/
-
-/*!
-\ingroup move_related
-\brief This version of move is selected when T is_movable . It in turn calls the move
-constructor. This call, with the help of the return value optimization, will cause x to be moved
-instead of copied to its destination. See adobe/test/move/main.cpp for examples.
-
-*/
-template <typename T>
-T move(T& x, typename move_sink<T>::type = 0) { return T(move_from<T>(x)); }
-
-/*************************************************************************************************/
-
-/*!
-\ingroup move_related
-\brief This version of move is selected when T is not movable . The net result will be that
-x gets copied.
-*/
-template <typename T>
-T& move(T& x, typename copy_sink<T>::type = 0) { return x; }
-
-/*************************************************************************************************/
-
-#else // BOOST_NO_SFINAE
-
-// On compilers without SFINAE, define copy_sink to always use the copy function.
-
-template <typename T,
- typename U = T,
- typename R = void*>
-struct copy_sink
-{
- typedef R type;
-};
-
-// Always copy the element unless this is overloaded.
-
-template <typename T>
-T& move(T& x) {
- return x;
-}
-
-#endif // BOOST_NO_SFINAE
-
-} // namespace unordered_detail
-} // namespace boost
-
-/*************************************************************************************************/
-
-#endif
-
-/*************************************************************************************************/

Modified: sandbox/move/boost/unordered/unordered_map.hpp
==============================================================================
--- sandbox/move/boost/unordered/unordered_map.hpp (original)
+++ sandbox/move/boost/unordered/unordered_map.hpp 2009-04-14 13:49:06 EDT (Tue, 14 Apr 2009)
@@ -1,3 +1,4 @@
+#include <iostream>
 
 // Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard.
 // Copyright (C) 2005-2009 Daniel James.
@@ -16,10 +17,7 @@
 #include <boost/unordered/unordered_map_fwd.hpp>
 #include <boost/functional/hash.hpp>
 #include <boost/unordered/detail/hash_table.hpp>
-
-#if !defined(BOOST_HAS_RVALUE_REFS)
-#include <boost/unordered/detail/move.hpp>
-#endif
+#include <boost/move/move.hpp>
 
 #if defined(BOOST_MSVC)
 #pragma warning(push)
@@ -104,36 +102,32 @@
         {
         }
 
-#if defined(BOOST_HAS_RVALUE_REFS)
- unordered_map(unordered_map&& other)
+ BOOST_ENABLE_MOVE_EMULATION(unordered_map)
+
+ unordered_map(BOOST_RV_REF(unordered_map) other)
             : base(other.base, boost::unordered_detail::move_tag())
         {
         }
 
- unordered_map(unordered_map&& other, allocator_type const& a)
+ unordered_map(BOOST_RV_REF(unordered_map) other, allocator_type const& a)
             : base(other.base, a, boost::unordered_detail::move_tag())
         {
         }
 
+
+#if defined(BOOST_HAS_RVALUE_REFS)
         unordered_map& operator=(unordered_map&& x)
         {
             base.move(x.base);
             return *this;
         }
-#else
- unordered_map(boost::unordered_detail::move_from<unordered_map<Key, T, Hash, Pred, Alloc> > other)
- : base(other.source.base, boost::unordered_detail::move_tag())
- {
- }
-
-#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0593)
+#elif !BOOST_WORKAROUND(__BORLANDC__, < 0x0593)
         unordered_map& operator=(unordered_map x)
         {
             base.move(x.base);
             return *this;
         }
 #endif
-#endif
 
 #if !defined(BOOST_NO_INITIALIZER_LISTS)
         unordered_map(std::initializer_list<value_type> list,
@@ -510,36 +504,31 @@
         {
         }
 
-#if defined(BOOST_HAS_RVALUE_REFS)
- unordered_multimap(unordered_multimap&& other)
+ BOOST_ENABLE_MOVE_EMULATION(unordered_multimap)
+
+ unordered_multimap(BOOST_RV_REF(unordered_multimap) other)
             : base(other.base, boost::unordered_detail::move_tag())
         {
         }
 
- unordered_multimap(unordered_multimap&& other, allocator_type const& a)
+ unordered_multimap(BOOST_RV_REF(unordered_multimap) other, allocator_type const& a)
             : base(other.base, a, boost::unordered_detail::move_tag())
         {
         }
 
+#if defined(BOOST_HAS_RVALUE_REFS)
         unordered_multimap& operator=(unordered_multimap&& x)
         {
             base.move(x.base);
             return *this;
         }
-#else
- unordered_multimap(boost::unordered_detail::move_from<unordered_multimap<Key, T, Hash, Pred, Alloc> > other)
- : base(other.source.base, boost::unordered_detail::move_tag())
- {
- }
-
-#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0593)
+#elif !BOOST_WORKAROUND(__BORLANDC__, < 0x0593)
         unordered_multimap& operator=(unordered_multimap x)
         {
             base.move(x.base);
             return *this;
         }
 #endif
-#endif
 
 #if !defined(BOOST_NO_INITIALIZER_LISTS)
         unordered_multimap(std::initializer_list<value_type> list,

Modified: sandbox/move/boost/unordered/unordered_set.hpp
==============================================================================
--- sandbox/move/boost/unordered/unordered_set.hpp (original)
+++ sandbox/move/boost/unordered/unordered_set.hpp 2009-04-14 13:49:06 EDT (Tue, 14 Apr 2009)
@@ -16,10 +16,7 @@
 #include <boost/unordered/unordered_set_fwd.hpp>
 #include <boost/functional/hash.hpp>
 #include <boost/unordered/detail/hash_table.hpp>
-
-#if !defined(BOOST_HAS_RVALUE_REFS)
-#include <boost/unordered/detail/move.hpp>
-#endif
+#include <boost/move/move.hpp>
 
 #if defined(BOOST_MSVC)
 #pragma warning(push)
@@ -102,36 +99,31 @@
         {
         }
 
-#if defined(BOOST_HAS_RVALUE_REFS)
- unordered_set(unordered_set&& other)
+ BOOST_ENABLE_MOVE_EMULATION(unordered_set)
+
+ unordered_set(BOOST_RV_REF(unordered_set) other)
             : base(other.base, boost::unordered_detail::move_tag())
         {
         }
 
- unordered_set(unordered_set&& other, allocator_type const& a)
+ unordered_set(BOOST_RV_REF(unordered_set) other, allocator_type const& a)
             : base(other.base, a, boost::unordered_detail::move_tag())
         {
         }
 
+#if defined(BOOST_HAS_RVALUE_REFS)
         unordered_set& operator=(unordered_set&& x)
         {
             base.move(x.base);
             return *this;
         }
-#else
- unordered_set(boost::unordered_detail::move_from<unordered_set<Value, Hash, Pred, Alloc> > other)
- : base(other.source.base, boost::unordered_detail::move_tag())
- {
- }
-
-#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0593)
+#elif !BOOST_WORKAROUND(__BORLANDC__, < 0x0593)
         unordered_set& operator=(unordered_set x)
         {
             base.move(x.base);
             return *this;
         }
 #endif
-#endif
 
 #if !defined(BOOST_NO_INITIALIZER_LISTS)
         unordered_set(std::initializer_list<value_type> list,
@@ -480,36 +472,31 @@
         {
         }
 
-#if defined(BOOST_HAS_RVALUE_REFS)
- unordered_multiset(unordered_multiset&& other)
+ BOOST_ENABLE_MOVE_EMULATION(unordered_multiset)
+
+ unordered_multiset(BOOST_RV_REF(unordered_multiset) other)
             : base(other.base, boost::unordered_detail::move_tag())
         {
         }
 
- unordered_multiset(unordered_multiset&& other, allocator_type const& a)
+ unordered_multiset(BOOST_RV_REF(unordered_multiset) other, allocator_type const& a)
             : base(other.base, a, boost::unordered_detail::move_tag())
         {
         }
 
+#if defined(BOOST_HAS_RVALUE_REFS)
         unordered_multiset& operator=(unordered_multiset&& x)
         {
             base.move(x.base);
             return *this;
         }
-#else
- unordered_multiset(boost::unordered_detail::move_from<unordered_multiset<Value, Hash, Pred, Alloc> > other)
- : base(other.source.base, boost::unordered_detail::move_tag())
- {
- }
-
-#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0593)
+#elif !BOOST_WORKAROUND(__BORLANDC__, < 0x0593)
         unordered_multiset& operator=(unordered_multiset x)
         {
             base.move(x.base);
             return *this;
         }
 #endif
-#endif
 
 #if !defined(BOOST_NO_INITIALIZER_LISTS)
         unordered_multiset(std::initializer_list<value_type> list,


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