From 6e07bb846c3697b1543913ed8d8feab38585e0ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Fri, 13 May 2016 00:22:20 +0200 Subject: [PATCH] Add three-way operations to move_op & swap_op --- include/boost/move/algo/detail/basic_op.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/boost/move/algo/detail/basic_op.hpp b/include/boost/move/algo/detail/basic_op.hpp index 936f7a2..ea0ce1b 100644 --- a/include/boost/move/algo/detail/basic_op.hpp +++ b/include/boost/move/algo/detail/basic_op.hpp @@ -21,12 +21,14 @@ #include #include +#include namespace boost { namespace movelib { struct forward_t{}; struct backward_t{}; +struct three_way_t{}; struct move_op { @@ -41,6 +43,13 @@ struct move_op template DestinationIt operator()(backward_t, SourceIt first, SourceIt last, DestinationIt dest_last) { return ::boost::move_backward(first, last, dest_last); } + + template + void operator()(three_way_t, SourceIt srcit, DestinationIt1 dest1it, DestinationIt2 dest2it) + { + *dest2it = boost::move(*dest1it); + *dest1it = boost::move(*srcit); + } }; struct swap_op @@ -56,6 +65,15 @@ struct swap_op template DestinationIt operator()(backward_t, SourceIt first, SourceIt last, DestinationIt dest_begin) { return boost::adl_move_swap_ranges_backward(first, last, dest_begin); } + + template + void operator()(three_way_t, SourceIt srcit, DestinationIt1 dest1it, DestinationIt2 dest2it) + { + typename ::boost::movelib::iterator_traits::value_type tmp(boost::move(*dest2it)); + *dest2it = boost::move(*dest1it); + *dest1it = boost::move(*srcit); + *srcit = boost::move(tmp); + } }; }} //namespace boost::movelib