comparison DEPENDENCIES/generic/include/boost/variant/detail/move.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
comparison
equal deleted inserted replaced
15:663ca0da4350 16:2665513ce2d3
1 //-----------------------------------------------------------------------------
2 // boost variant/detail/move.hpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
5 //
6 // Copyright (c) 2002-2003 Eric Friedman
7 // Copyright (c) 2002 by Andrei Alexandrescu
8 //
9 // Use, modification and distribution are subject to the
10 // Boost Software License, Version 1.0. (See accompanying file
11 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
12 //
13 // This file derivative of MoJO. Much thanks to Andrei for his initial work.
14 // See <http://www.cuj.com/experts/2102/alexandr.htm> for information on MOJO.
15 // Re-issued here under the Boost Software License, with permission of the original
16 // author (Andrei Alexandrescu).
17
18
19 #ifndef BOOST_VARIANT_DETAIL_MOVE_HPP
20 #define BOOST_VARIANT_DETAIL_MOVE_HPP
21
22 #include <iterator> // for iterator_traits
23 #include <new> // for placement new
24
25 #include "boost/config.hpp"
26 #include "boost/detail/workaround.hpp"
27 #include "boost/move/move.hpp"
28
29 namespace boost {
30 namespace detail { namespace variant {
31
32 using boost::move;
33
34 //////////////////////////////////////////////////////////////////////////
35 // function template move_swap
36 //
37 // Swaps using Koenig lookup but falls back to move-swap for primitive
38 // types and on non-conforming compilers.
39 //
40
41 #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) \
42 || BOOST_WORKAROUND(__GNUC__, BOOST_TESTED_AT(2))
43
44 // [Indicate that move_swap by overload is disabled...]
45 #define BOOST_NO_MOVE_SWAP_BY_OVERLOAD
46
47 // [...and provide straight swap-by-move implementation:]
48 template <typename T>
49 inline void move_swap(T& lhs, T& rhs)
50 {
51 T tmp( boost::detail::variant::move(lhs) );
52 lhs = boost::detail::variant::move(rhs);
53 rhs = boost::detail::variant::move(tmp);
54 }
55
56 #else// !workaround
57
58 namespace detail { namespace move_swap {
59
60 template <typename T>
61 inline void swap(T& lhs, T& rhs)
62 {
63 T tmp( boost::detail::variant::move(lhs) );
64 lhs = boost::detail::variant::move(rhs);
65 rhs = boost::detail::variant::move(tmp);
66 }
67
68 }} // namespace detail::move_swap
69
70 template <typename T>
71 inline void move_swap(T& lhs, T& rhs)
72 {
73 using detail::move_swap::swap;
74
75 swap(lhs, rhs);
76 }
77
78 #endif // workaround
79
80 }} // namespace detail::variant
81 } // namespace boost
82
83 #endif // BOOST_VARIANT_DETAIL_MOVE_HPP
84
85
86