From 99f3f04d0494191865c3e93c88adc2ba579349f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Thu, 6 Apr 2017 22:10:28 +0200 Subject: [PATCH 1/8] Add forceinline --- include/boost/move/algo/detail/basic_op.hpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/boost/move/algo/detail/basic_op.hpp b/include/boost/move/algo/detail/basic_op.hpp index a9369e0..ea5faf0 100644 --- a/include/boost/move/algo/detail/basic_op.hpp +++ b/include/boost/move/algo/detail/basic_op.hpp @@ -35,19 +35,19 @@ struct four_way_t{}; struct move_op { template - void operator()(SourceIt source, DestinationIt dest) + BOOST_MOVE_FORCEINLINE void operator()(SourceIt source, DestinationIt dest) { *dest = ::boost::move(*source); } template - DestinationIt operator()(forward_t, SourceIt first, SourceIt last, DestinationIt dest_begin) + BOOST_MOVE_FORCEINLINE DestinationIt operator()(forward_t, SourceIt first, SourceIt last, DestinationIt dest_begin) { return ::boost::move(first, last, dest_begin); } template - DestinationIt operator()(backward_t, SourceIt first, SourceIt last, DestinationIt dest_last) + BOOST_MOVE_FORCEINLINE 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) + BOOST_MOVE_FORCEINLINE void operator()(three_way_t, SourceIt srcit, DestinationIt1 dest1it, DestinationIt2 dest2it) { *dest2it = boost::move(*dest1it); *dest1it = boost::move(*srcit); @@ -64,7 +64,7 @@ struct move_op } template - void operator()(four_way_t, SourceIt srcit, DestinationIt1 dest1it, DestinationIt2 dest2it, DestinationIt3 dest3it) + BOOST_MOVE_FORCEINLINE void operator()(four_way_t, SourceIt srcit, DestinationIt1 dest1it, DestinationIt2 dest2it, DestinationIt3 dest3it) { *dest3it = boost::move(*dest2it); *dest2it = boost::move(*dest1it); @@ -75,19 +75,19 @@ struct move_op struct swap_op { template - void operator()(SourceIt source, DestinationIt dest) + BOOST_MOVE_FORCEINLINE void operator()(SourceIt source, DestinationIt dest) { boost::adl_move_swap(*dest, *source); } template - DestinationIt operator()(forward_t, SourceIt first, SourceIt last, DestinationIt dest_begin) + BOOST_MOVE_FORCEINLINE DestinationIt operator()(forward_t, SourceIt first, SourceIt last, DestinationIt dest_begin) { return boost::adl_move_swap_ranges(first, last, dest_begin); } template - DestinationIt operator()(backward_t, SourceIt first, SourceIt last, DestinationIt dest_begin) + BOOST_MOVE_FORCEINLINE 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) + BOOST_MOVE_FORCEINLINE 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); @@ -105,7 +105,7 @@ struct swap_op } template - void operator()(four_way_t, SourceIt srcit, DestinationIt1 dest1it, DestinationIt2 dest2it, DestinationIt3 dest3it) + BOOST_MOVE_FORCEINLINE void operator()(four_way_t, SourceIt srcit, DestinationIt1 dest1it, DestinationIt2 dest2it, DestinationIt3 dest3it) { typename ::boost::movelib::iterator_traits::value_type tmp(boost::move(*dest3it)); *dest3it = boost::move(*dest2it); From a2d08c908d4a7abc037cb02d5e7a5517be29ea97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Thu, 6 Apr 2017 22:17:18 +0200 Subject: [PATCH 2/8] Add new macro that obtains the type of the last argument --- include/boost/move/detail/fwd_macros.hpp | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/boost/move/detail/fwd_macros.hpp b/include/boost/move/detail/fwd_macros.hpp index 7132436..a5df5f1 100644 --- a/include/boost/move/detail/fwd_macros.hpp +++ b/include/boost/move/detail/fwd_macros.hpp @@ -458,6 +458,31 @@ namespace move_detail { #define BOOST_MOVE_CLASSDFLTQ8 BOOST_MOVE_CLASSDFLTQ7, class Q7 = void #define BOOST_MOVE_CLASSDFLTQ9 BOOST_MOVE_CLASSDFLTQ8, class Q8 = void +//BOOST_MOVE_LAST_TARGN +#define BOOST_MOVE_LAST_TARG0 void +#define BOOST_MOVE_LAST_TARG1 P0 +#define BOOST_MOVE_LAST_TARG2 P1 +#define BOOST_MOVE_LAST_TARG3 P2 +#define BOOST_MOVE_LAST_TARG4 P3 +#define BOOST_MOVE_LAST_TARG5 P4 +#define BOOST_MOVE_LAST_TARG6 P5 +#define BOOST_MOVE_LAST_TARG7 P6 +#define BOOST_MOVE_LAST_TARG8 P7 +#define BOOST_MOVE_LAST_TARG9 P8 + +//BOOST_MOVE_LAST_TARGQN +#define BOOST_MOVE_LAST_TARGQ0 void +#define BOOST_MOVE_LAST_TARGQ1 Q0 +#define BOOST_MOVE_LAST_TARGQ2 Q1 +#define BOOST_MOVE_LAST_TARGQ3 Q2 +#define BOOST_MOVE_LAST_TARGQ4 Q3 +#define BOOST_MOVE_LAST_TARGQ5 Q4 +#define BOOST_MOVE_LAST_TARGQ6 Q5 +#define BOOST_MOVE_LAST_TARGQ7 Q6 +#define BOOST_MOVE_LAST_TARGQ8 Q7 +#define BOOST_MOVE_LAST_TARGQ9 Q8 + + //BOOST_MOVE_TARGN #define BOOST_MOVE_TARG0 #define BOOST_MOVE_TARG1 P0 From 21cb31ad7172edc96c1715f22d51c67853e61ee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Thu, 6 Apr 2017 22:51:10 +0200 Subject: [PATCH 3/8] New low-level utilities to deal with pointers and iterators --- .../move/detail/iterator_to_raw_pointer.hpp | 59 ++++++ include/boost/move/detail/pointer_element.hpp | 168 ++++++++++++++++++ include/boost/move/detail/to_raw_pointer.hpp | 45 +++++ 3 files changed, 272 insertions(+) create mode 100644 include/boost/move/detail/iterator_to_raw_pointer.hpp create mode 100644 include/boost/move/detail/pointer_element.hpp create mode 100644 include/boost/move/detail/to_raw_pointer.hpp diff --git a/include/boost/move/detail/iterator_to_raw_pointer.hpp b/include/boost/move/detail/iterator_to_raw_pointer.hpp new file mode 100644 index 0000000..97ee3a6 --- /dev/null +++ b/include/boost/move/detail/iterator_to_raw_pointer.hpp @@ -0,0 +1,59 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_MOVE_DETAIL_ITERATOR_TO_RAW_POINTER_HPP +#define BOOST_MOVE_DETAIL_ITERATOR_TO_RAW_POINTER_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include +#include +#include + +namespace boost { +namespace movelib { +namespace detail { + +template +inline T* iterator_to_pointer(T* i) +{ return i; } + +template +inline typename boost::movelib::iterator_traits::pointer + iterator_to_pointer(const Iterator &i) +{ return i.operator->(); } + +template +struct iterator_to_element_ptr +{ + typedef typename boost::movelib::iterator_traits::pointer pointer; + typedef typename boost::movelib::pointer_element::type element_type; + typedef element_type* type; +}; + +} //namespace detail { + +template +inline typename boost::movelib::detail::iterator_to_element_ptr::type + iterator_to_raw_pointer(const Iterator &i) +{ + return ::boost::movelib::to_raw_pointer + ( ::boost::movelib::detail::iterator_to_pointer(i) ); +} + +} //namespace movelib { +} //namespace boost { + +#endif //#ifndef BOOST_MOVE_DETAIL_ITERATOR_TO_RAW_POINTER_HPP diff --git a/include/boost/move/detail/pointer_element.hpp b/include/boost/move/detail/pointer_element.hpp new file mode 100644 index 0000000..ecdd608 --- /dev/null +++ b/include/boost/move/detail/pointer_element.hpp @@ -0,0 +1,168 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2017. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/move for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_MOVE_DETAIL_POINTER_ELEMENT_HPP +#define BOOST_MOVE_DETAIL_POINTER_ELEMENT_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#ifndef BOOST_MOVE_DETAIL_WORKAROUND_HPP +#include +#endif //BOOST_MOVE_DETAIL_WORKAROUND_HPP + +namespace boost { +namespace movelib { +namespace detail{ + +////////////////////// +//struct first_param +////////////////////// + +template struct first_param +{ typedef void type; }; + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + + template