From c6f784cb7034b0a8c3183086fcd7ed8389e50a03 Mon Sep 17 00:00:00 2001 From: Ben10do Date: Wed, 1 Aug 2018 20:54:17 +0100 Subject: [PATCH] Use forwarding references in string/split.hpp On compilers that support C++11, this allows both lvalues and rvalues to be used as inputs to the split(), find_all(), and ifind_all() functions. For example, given a function get_string() that returns a std::string, this allows you to write: boost::split(result, get_string(), boost::is_any_of(" ")) --- include/boost/algorithm/string/iter_find.hpp | 8 ++++++++ include/boost/algorithm/string/split.hpp | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/boost/algorithm/string/iter_find.hpp b/include/boost/algorithm/string/iter_find.hpp index 10424ab..d76a819 100644 --- a/include/boost/algorithm/string/iter_find.hpp +++ b/include/boost/algorithm/string/iter_find.hpp @@ -71,7 +71,11 @@ namespace boost { inline SequenceSequenceT& iter_find( SequenceSequenceT& Result, +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + RangeT&& Input, +#else RangeT& Input, +#endif FinderT Finder ) { BOOST_CONCEPT_ASSERT(( @@ -142,7 +146,11 @@ namespace boost { inline SequenceSequenceT& iter_split( SequenceSequenceT& Result, +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + RangeT&& Input, +#else RangeT& Input, +#endif FinderT Finder ) { BOOST_CONCEPT_ASSERT(( diff --git a/include/boost/algorithm/string/split.hpp b/include/boost/algorithm/string/split.hpp index cae712c..e0b30fb 100644 --- a/include/boost/algorithm/string/split.hpp +++ b/include/boost/algorithm/string/split.hpp @@ -61,7 +61,11 @@ namespace boost { template< typename SequenceSequenceT, typename Range1T, typename Range2T > inline SequenceSequenceT& find_all( SequenceSequenceT& Result, +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + Range1T&& Input, +#else Range1T& Input, +#endif const Range2T& Search) { return ::boost::algorithm::iter_find( @@ -96,7 +100,11 @@ namespace boost { template< typename SequenceSequenceT, typename Range1T, typename Range2T > inline SequenceSequenceT& ifind_all( SequenceSequenceT& Result, +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + Range1T&& Input, +#else Range1T& Input, +#endif const Range2T& Search, const std::locale& Loc=std::locale() ) { @@ -139,7 +147,11 @@ namespace boost { template< typename SequenceSequenceT, typename RangeT, typename PredicateT > inline SequenceSequenceT& split( SequenceSequenceT& Result, +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + RangeT&& Input, +#else RangeT& Input, +#endif PredicateT Pred, token_compress_mode_type eCompress=token_compress_off ) {