From 29855f3aabd56500b5872ed95077ab93fc8bf0fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Tue, 17 Mar 2026 15:28:49 +0100 Subject: [PATCH] Move the function object to supprot move-only function objects --- .../experimental/segmented_for_each.hpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/include/boost/container/experimental/segmented_for_each.hpp b/include/boost/container/experimental/segmented_for_each.hpp index ba1ac14..e27a857 100644 --- a/include/boost/container/experimental/segmented_for_each.hpp +++ b/include/boost/container/experimental/segmented_for_each.hpp @@ -21,6 +21,7 @@ #include #include #include +#include namespace boost { namespace container { @@ -37,14 +38,15 @@ F segmented_for_each_dispatch typedef segmented_iterator_traits traits; typename traits::segment_iterator sfirst = traits::segment(first); typename traits::segment_iterator slast = traits::segment(last); + if(sfirst == slast) { - f = boost::container::segmented_for_each(traits::local(first), traits::local(last), f); + f = boost::container::segmented_for_each(traits::local(first), traits::local(last), boost::move(f)); } else { - f = boost::container::segmented_for_each(traits::local(first), traits::end(sfirst), f); + f = boost::container::segmented_for_each(traits::local(first), traits::end(sfirst), boost::move(f)); for(++sfirst; sfirst != slast; ++sfirst) - f = boost::container::segmented_for_each(traits::begin(sfirst), traits::end(sfirst), f); - f = boost::container::segmented_for_each(traits::begin(sfirst), traits::local(last), f); + f = boost::container::segmented_for_each(traits::begin(sfirst), traits::end(sfirst), boost::move(f)); + f = boost::container::segmented_for_each(traits::begin(sfirst), traits::local(last), boost::move(f)); } return f; } @@ -67,11 +69,11 @@ segmented_for_each_dispatch //! When \c Iter is a segmented iterator, exploits segmentation //! to reduce per-element overhead. template -BOOST_CONTAINER_FORCEINLINE F segmented_for_each(InpIter first, Sent last, F f) +BOOST_CONTAINER_FORCEINLINE +F segmented_for_each(InpIter first, Sent last, F f) { typedef segmented_iterator_traits traits; - return detail_algo::segmented_for_each_dispatch(first, last, f, - typename traits::is_segmented_iterator()); + return detail_algo::segmented_for_each_dispatch(first, last, boost::move(f), typename traits::is_segmented_iterator()); } } // namespace container