|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r50487 - in sandbox/move: boost/move libs/move/test
From: daniel_james_at_[hidden]
Date: 2009-01-05 17:55:39
Author: danieljames
Date: 2009-01-05 17:55:39 EST (Mon, 05 Jan 2009)
New Revision: 50487
URL: http://svn.boost.org/trac/boost/changeset/50487
Log:
Don't use move by swap by default.
Text files modified:
sandbox/move/boost/move/move.hpp | 18 ++++++++++++++----
sandbox/move/libs/move/test/main.cpp | 2 +-
sandbox/move/libs/move/test/move.cpp | 2 +-
sandbox/move/libs/move/test/swappable.cpp | 9 +++++++++
sandbox/move/libs/move/test/x.hpp | 2 ++
5 files changed, 27 insertions(+), 6 deletions(-)
Modified: sandbox/move/boost/move/move.hpp
==============================================================================
--- sandbox/move/boost/move/move.hpp (original)
+++ sandbox/move/boost/move/move.hpp 2009-01-05 17:55:39 EST (Mon, 05 Jan 2009)
@@ -29,7 +29,9 @@
#include <boost/type_traits/is_class.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/move/detail/config.hpp>
-#include <boost/move/detail/has_swap_overload.hpp>
+
+// This is needed if you want to use move by swap by default:
+//#include <boost/move/detail/has_swap_overload.hpp>
/*************************************************************************************************/
@@ -159,11 +161,19 @@
\brief The move_type trait is used to identify which move technique should be
used for this type.
*/
+
template <typename T, class Enable = void>
struct move_type :
- boost::mpl::if_<is_boost_movable<T>, boost_move_tag,
- typename boost::mpl::if_<boost::detail::has_swap_overload<T>,
- swap_tag, copy_tag>::type > {};
+ boost::mpl::if_<is_boost_movable<T>, boost_move_tag, copy_tag> {};
+
+// I'm not automatically moving by swap for now, but this is how it
+// was implemented:
+//
+//template <typename T, class Enable = void>
+//struct move_type :
+// boost::mpl::if_<is_boost_movable<T>, boost_move_tag,
+// typename boost::mpl::if_<boost::detail::has_swap_overload<T>,
+// swap_tag, copy_tag>::type > {};
/*!
\ingroup move_related
Modified: sandbox/move/libs/move/test/main.cpp
==============================================================================
--- sandbox/move/libs/move/test/main.cpp (original)
+++ sandbox/move/libs/move/test/main.cpp 2009-01-05 17:55:39 EST (Mon, 05 Jan 2009)
@@ -51,7 +51,7 @@
// Test is_movable<> template function
- BOOST_CHECK(boost::is_movable<std_vector_t>::value);
+ BOOST_CHECK(!boost::is_movable<std_vector_t>::value);
BOOST_CHECK(boost::is_movable<vector_t>::value);
{ // Test move_sink<> via push_back
Modified: sandbox/move/libs/move/test/move.cpp
==============================================================================
--- sandbox/move/libs/move/test/move.cpp (original)
+++ sandbox/move/libs/move/test/move.cpp 2009-01-05 17:55:39 EST (Mon, 05 Jan 2009)
@@ -144,7 +144,7 @@
z10 = boost::move(z8);
SAY(" ------ test 25, request move construct from non-movable lvalue ------- ");
- BOOST_STATIC_ASSERT(boost::is_movable<std::string>::value);
+ BOOST_STATIC_ASSERT(!boost::is_movable<std::string>::value);
std::string s1("hello");
std::string s2(boost::move(s1));
Modified: sandbox/move/libs/move/test/swappable.cpp
==============================================================================
--- sandbox/move/libs/move/test/swappable.cpp (original)
+++ sandbox/move/libs/move/test/swappable.cpp 2009-01-05 17:55:39 EST (Mon, 05 Jan 2009)
@@ -86,6 +86,14 @@
static bool move_expected;
};
+// Tell boost to move by swap.
+// We probably need a better customization hook.
+
+namespace boost {
+ template <>
+ struct move_type<Swappable> { typedef boost::swap_tag type; };
+}
+
int Swappable::cnt;
int Swappable::copies;
int Swappable::suboptimal_copies;
@@ -226,6 +234,7 @@
Swappable::expect_move();
Swappable z11 = boost::move(z9);
+ // TODO: This is failing:
SAY(" ------ test 24, move assign from movable lvalue ------- ");
Swappable::expect_move();
z10 = boost::move(z8);
Modified: sandbox/move/libs/move/test/x.hpp
==============================================================================
--- sandbox/move/libs/move/test/x.hpp (original)
+++ sandbox/move/libs/move/test/x.hpp 2009-01-05 17:55:39 EST (Mon, 05 Jan 2009)
@@ -62,6 +62,8 @@
static void expect_copy() { copy_expected = true; move_expected = false; }
static void expect_move() { copy_expected = false; move_expected = true; }
+ operator boost::move_from<X>() { return *this; }
+
private: // helper functions
void release()
{
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