Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:40:51

0001 //////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga 2015-2016.
0004 // Distributed under the Boost Software License, Version 1.0.
0005 // (See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt)
0007 //
0008 // See http://www.boost.org/libs/move for documentation.
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 #if defined(BOOST_HAS_PRAGMA_ONCE)
0019 #  pragma once
0020 #endif
0021 
0022 #include <boost/move/utility_core.hpp>
0023 #include <boost/move/adl_move_swap.hpp>
0024 #include <boost/move/detail/iterator_traits.hpp>
0025 #include <boost/move/algo/move.hpp>
0026 
0027 namespace boost {
0028 namespace movelib {
0029 
0030 struct forward_t{};
0031 struct backward_t{};
0032 struct three_way_t{};
0033 struct three_way_forward_t{};
0034 struct four_way_t{};
0035 
0036 struct move_op
0037 {
0038    template <class SourceIt, class DestinationIt>
0039    BOOST_MOVE_FORCEINLINE void operator()(SourceIt source, DestinationIt dest)
0040    {  *dest = ::boost::move(*source);  }
0041 
0042    template <class SourceIt, class DestinationIt>
0043    BOOST_MOVE_FORCEINLINE DestinationIt operator()(forward_t, SourceIt first, SourceIt last, DestinationIt dest_begin)
0044    {  return ::boost::move(first, last, dest_begin);  }
0045 
0046    template <class SourceIt, class DestinationIt>
0047    BOOST_MOVE_FORCEINLINE DestinationIt operator()(backward_t, SourceIt first, SourceIt last, DestinationIt dest_last)
0048    {  return ::boost::move_backward(first, last, dest_last);  }
0049 
0050    template <class SourceIt, class DestinationIt1, class DestinationIt2>
0051    BOOST_MOVE_FORCEINLINE void operator()(three_way_t, SourceIt srcit, DestinationIt1 dest1it, DestinationIt2 dest2it)
0052    {
0053       *dest2it = boost::move(*dest1it);
0054       *dest1it = boost::move(*srcit);
0055    }
0056 
0057    template <class SourceIt, class DestinationIt1, class DestinationIt2>
0058    DestinationIt2 operator()(three_way_forward_t, SourceIt srcit, SourceIt srcitend, DestinationIt1 dest1it, DestinationIt2 dest2it)
0059    {
0060       //Destination2 range can overlap SourceIt range so avoid boost::move
0061       while(srcit != srcitend){
0062          this->operator()(three_way_t(), srcit++, dest1it++, dest2it++);
0063       }
0064       return dest2it;
0065    }
0066 
0067    template <class SourceIt, class DestinationIt1, class DestinationIt2, class DestinationIt3>
0068    BOOST_MOVE_FORCEINLINE void operator()(four_way_t, SourceIt srcit, DestinationIt1 dest1it, DestinationIt2 dest2it, DestinationIt3 dest3it)
0069    {
0070       *dest3it = boost::move(*dest2it);
0071       *dest2it = boost::move(*dest1it);
0072       *dest1it = boost::move(*srcit);
0073    }
0074 };
0075 
0076 struct swap_op
0077 {
0078    template <class SourceIt, class DestinationIt>
0079    BOOST_MOVE_FORCEINLINE void operator()(SourceIt source, DestinationIt dest)
0080    {  boost::adl_move_swap(*dest, *source);  }
0081 
0082    template <class SourceIt, class DestinationIt>
0083    BOOST_MOVE_FORCEINLINE DestinationIt operator()(forward_t, SourceIt first, SourceIt last, DestinationIt dest_begin)
0084    {  return boost::adl_move_swap_ranges(first, last, dest_begin);  }
0085 
0086    template <class SourceIt, class DestinationIt>
0087    BOOST_MOVE_FORCEINLINE DestinationIt operator()(backward_t, SourceIt first, SourceIt last, DestinationIt dest_begin)
0088    {  return boost::adl_move_swap_ranges_backward(first, last, dest_begin);  }
0089 
0090    template <class SourceIt, class DestinationIt1, class DestinationIt2>
0091    BOOST_MOVE_FORCEINLINE void operator()(three_way_t, SourceIt srcit, DestinationIt1 dest1it, DestinationIt2 dest2it)
0092    {
0093       typename ::boost::movelib::iterator_traits<SourceIt>::value_type tmp(boost::move(*dest2it));
0094       *dest2it = boost::move(*dest1it);
0095       *dest1it = boost::move(*srcit);
0096       *srcit = boost::move(tmp);
0097    }
0098 
0099    template <class SourceIt, class DestinationIt1, class DestinationIt2>
0100    DestinationIt2 operator()(three_way_forward_t, SourceIt srcit, SourceIt srcitend, DestinationIt1 dest1it, DestinationIt2 dest2it)
0101    {
0102       while(srcit != srcitend){
0103          this->operator()(three_way_t(), srcit++, dest1it++, dest2it++);
0104       }
0105       return dest2it;
0106    }
0107 
0108    template <class SourceIt, class DestinationIt1, class DestinationIt2, class DestinationIt3>
0109    BOOST_MOVE_FORCEINLINE void operator()(four_way_t, SourceIt srcit, DestinationIt1 dest1it, DestinationIt2 dest2it, DestinationIt3 dest3it)
0110    {
0111       typename ::boost::movelib::iterator_traits<SourceIt>::value_type tmp(boost::move(*dest3it));
0112       *dest3it = boost::move(*dest2it);
0113       *dest2it = boost::move(*dest1it);
0114       *dest1it = boost::move(*srcit);
0115       *srcit = boost::move(tmp);
0116    }
0117 };
0118 
0119 
0120 }} //namespace boost::movelib
0121 
0122 #endif   //BOOST_MOVE_ALGO_BASIC_OP