File indexing completed on 2026-03-29 08:07:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_MOVE_ALGO_BASIC_OP
0012 #define BOOST_MOVE_ALGO_BASIC_OP
0013
0014 #ifndef BOOST_CONFIG_HPP
0015 # include <boost/config.hpp>
0016 #endif
0017 0018 ">#
0019 #if defined(BOOST_HAS_PRAGMA_ONCE)
0020 # pragma once
0021 #endif
0022
0023 #include <boost/move/utility_core.hpp>
0024 #include <boost/move/adl_move_swap.hpp>
0025 #include <boost/move/detail/iterator_traits.hpp>
0026 #include <boost/move/algo/move.hpp>
0027
0028 namespace boost {
0029 namespace movelib {
0030
0031 struct forward_t{};
0032 struct backward_t{};
0033 struct three_way_t{};
0034 struct three_way_forward_t{};
0035 struct four_way_t{};
0036
0037 struct move_op
0038 {
0039 template <class SourceIt, class DestinationIt>
0040 inline void operator()(SourceIt source, DestinationIt dest)
0041 { *dest = ::boost::move(*source); }
0042
0043 template <class SourceIt, class DestinationIt>
0044 inline DestinationIt operator()(forward_t, SourceIt first, SourceIt last, DestinationIt dest_begin)
0045 { return ::boost::move(first, last, dest_begin); }
0046
0047 template <class SourceIt, class DestinationIt>
0048 inline DestinationIt operator()(backward_t, SourceIt first, SourceIt last, DestinationIt dest_last)
0049 { return ::boost::move_backward(first, last, dest_last); }
0050
0051 template <class SourceIt, class DestinationIt1, class DestinationIt2>
0052 inline void operator()(three_way_t, SourceIt srcit, DestinationIt1 dest1it, DestinationIt2 dest2it)
0053 {
0054 *dest2it = boost::move(*dest1it);
0055 *dest1it = boost::move(*srcit);
0056 }
0057
0058 template <class SourceIt, class DestinationIt1, class DestinationIt2>
0059 DestinationIt2 operator()(three_way_forward_t, SourceIt srcit, SourceIt srcitend, DestinationIt1 dest1it, DestinationIt2 dest2it)
0060 {
0061
0062 while(srcit != srcitend){
0063 this->operator()(three_way_t(), srcit++, dest1it++, dest2it++);
0064 }
0065 return dest2it;
0066 }
0067
0068 template <class SourceIt, class DestinationIt1, class DestinationIt2, class DestinationIt3>
0069 inline void operator()(four_way_t, SourceIt srcit, DestinationIt1 dest1it, DestinationIt2 dest2it, DestinationIt3 dest3it)
0070 {
0071 *dest3it = boost::move(*dest2it);
0072 *dest2it = boost::move(*dest1it);
0073 *dest1it = boost::move(*srcit);
0074 }
0075 };
0076
0077 struct swap_op
0078 {
0079 template <class SourceIt, class DestinationIt>
0080 inline void operator()(SourceIt source, DestinationIt dest)
0081 { boost::adl_move_swap(*dest, *source); }
0082
0083 template <class SourceIt, class DestinationIt>
0084 inline DestinationIt operator()(forward_t, SourceIt first, SourceIt last, DestinationIt dest_begin)
0085 { return boost::adl_move_swap_ranges(first, last, dest_begin); }
0086
0087 template <class SourceIt, class DestinationIt>
0088 inline DestinationIt operator()(backward_t, SourceIt first, SourceIt last, DestinationIt dest_begin)
0089 { return boost::adl_move_swap_ranges_backward(first, last, dest_begin); }
0090
0091 template <class SourceIt, class DestinationIt1, class DestinationIt2>
0092 inline void operator()(three_way_t, SourceIt srcit, DestinationIt1 dest1it, DestinationIt2 dest2it)
0093 {
0094 typename ::boost::movelib::iterator_traits<SourceIt>::value_type tmp(boost::move(*dest2it));
0095 *dest2it = boost::move(*dest1it);
0096 *dest1it = boost::move(*srcit);
0097 *srcit = boost::move(tmp);
0098 }
0099
0100 template <class SourceIt, class DestinationIt1, class DestinationIt2>
0101 DestinationIt2 operator()(three_way_forward_t, SourceIt srcit, SourceIt srcitend, DestinationIt1 dest1it, DestinationIt2 dest2it)
0102 {
0103 while(srcit != srcitend){
0104 this->operator()(three_way_t(), srcit++, dest1it++, dest2it++);
0105 }
0106 return dest2it;
0107 }
0108
0109 template <class SourceIt, class DestinationIt1, class DestinationIt2, class DestinationIt3>
0110 inline void operator()(four_way_t, SourceIt srcit, DestinationIt1 dest1it, DestinationIt2 dest2it, DestinationIt3 dest3it)
0111 {
0112 typename ::boost::movelib::iterator_traits<SourceIt>::value_type tmp(boost::move(*dest3it));
0113 *dest3it = boost::move(*dest2it);
0114 *dest2it = boost::move(*dest1it);
0115 *dest1it = boost::move(*srcit);
0116 *srcit = boost::move(tmp);
0117 }
0118 };
0119
0120
0121 }}
0122
0123 #endif