|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r85927 - in trunk: boost/variant boost/variant/detail libs/variant/test
From: antoshkka_at_[hidden]
Date: 2013-09-26 03:29:25
Author: apolukhin
Date: 2013-09-26 03:29:25 EDT (Thu, 26 Sep 2013)
New Revision: 85927
URL: http://svn.boost.org/trac/boost/changeset/85927
Log:
Optimize and fix ambiguity of move_swap in Boost.Variant (refs #2839)
Fix GCC-4.8+ warning in variant_reference_test.cpp
Text files modified:
trunk/boost/variant/detail/move.hpp | 43 ++++++++++++---------------------------
trunk/boost/variant/variant.hpp | 2
trunk/libs/variant/test/Jamfile.v2 | 1
trunk/libs/variant/test/variant_reference_test.cpp | 2 -
4 files changed, 15 insertions(+), 33 deletions(-)
Modified: trunk/boost/variant/detail/move.hpp
==============================================================================
--- trunk/boost/variant/detail/move.hpp Thu Sep 26 02:54:33 2013 (r85926)
+++ trunk/boost/variant/detail/move.hpp 2013-09-26 03:29:25 EDT (Thu, 26 Sep 2013) (r85927)
@@ -5,6 +5,7 @@
//
// Copyright (c) 2002-2003 Eric Friedman
// Copyright (c) 2002 by Andrei Alexandrescu
+// Copyright (c) 2013 Antony Polukhin
//
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
@@ -26,8 +27,7 @@
#include "boost/detail/workaround.hpp"
#include "boost/move/move.hpp"
-namespace boost {
-namespace detail { namespace variant {
+namespace boost { namespace detail { namespace variant {
using boost::move;
@@ -38,47 +38,30 @@
// types and on non-conforming compilers.
//
-#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) \
- || BOOST_WORKAROUND(__GNUC__, BOOST_TESTED_AT(2))
+namespace move_swap_fallback {
-// [Indicate that move_swap by overload is disabled...]
-#define BOOST_NO_MOVE_SWAP_BY_OVERLOAD
-
-// [...and provide straight swap-by-move implementation:]
-template <typename T>
-inline void move_swap(T& lhs, T& rhs)
+template <typename T1, typename T2>
+inline void swap(T1& lhs, T2& rhs)
{
- T tmp( boost::detail::variant::move(lhs) );
+ T1 tmp( boost::detail::variant::move(lhs) );
lhs = boost::detail::variant::move(rhs);
rhs = boost::detail::variant::move(tmp);
}
-#else// !workaround
-
-namespace detail { namespace move_swap {
-
-template <typename T>
-inline void swap(T& lhs, T& rhs)
-{
- T tmp( boost::detail::variant::move(lhs) );
- lhs = boost::detail::variant::move(rhs);
- rhs = boost::detail::variant::move(tmp);
-}
-
-}} // namespace detail::move_swap
+} // namespace move_swap_fallback
template <typename T>
inline void move_swap(T& lhs, T& rhs)
{
- using detail::move_swap::swap;
-
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+ move_swap_fallback::swap(lhs, rhs);
+#else
+ using move_swap_fallback::swap;
swap(lhs, rhs);
+#endif
}
-#endif // workaround
-
-}} // namespace detail::variant
-} // namespace boost
+}}} // namespace boost::detail::variant
#endif // BOOST_VARIANT_DETAIL_MOVE_HPP
Modified: trunk/boost/variant/variant.hpp
==============================================================================
--- trunk/boost/variant/variant.hpp Thu Sep 26 02:54:33 2013 (r85926)
+++ trunk/boost/variant/variant.hpp 2013-09-26 03:29:25 EDT (Thu, 26 Sep 2013) (r85927)
@@ -897,7 +897,7 @@
public: // structors
- explicit swap_with(Variant& toswap)
+ explicit swap_with(Variant& toswap) BOOST_NOEXCEPT
: toswap_(toswap)
{
}
Modified: trunk/libs/variant/test/Jamfile.v2
==============================================================================
--- trunk/libs/variant/test/Jamfile.v2 Thu Sep 26 02:54:33 2013 (r85926)
+++ trunk/libs/variant/test/Jamfile.v2 2013-09-26 03:29:25 EDT (Thu, 26 Sep 2013) (r85927)
@@ -53,6 +53,7 @@
<toolset>clang:<cxxflags>-fno-exceptions
: variant_noexcept_test
]
+ [ run variant_swap_test.cpp ]
;
Modified: trunk/libs/variant/test/variant_reference_test.cpp
==============================================================================
--- trunk/libs/variant/test/variant_reference_test.cpp Thu Sep 26 02:54:33 2013 (r85926)
+++ trunk/libs/variant/test/variant_reference_test.cpp 2013-09-26 03:29:25 EDT (Thu, 26 Sep 2013) (r85927)
@@ -77,8 +77,6 @@
template <typename Base, typename Derived>
void base_derived_test(Derived d)
{
- typedef typename boost::is_pointer<Base>::type is_ptr;
-
Base b(d);
BOOST_CHECK((check_base_derived(
b
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