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 ) { diff --git a/string/test/split_test.cpp b/string/test/split_test.cpp index 582472b..3dbcfac 100644 --- a/string/test/split_test.cpp +++ b/string/test/split_test.cpp @@ -7,6 +7,8 @@ // See http://www.boost.org for updates, documentation, and revision history. +#include + #include #include // equals predicate is used for result comparison @@ -82,6 +84,28 @@ void iterator_test() string("xx") ); deep_compare( tokens, vtokens ); +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + // If using a compiler that supports forwarding references, we should be able to use rvalues, too + find_all( + tokens, + string("xx-abc--xx-abb"), + "xx" ); + + BOOST_REQUIRE( tokens.size()==2 ); + BOOST_CHECK( tokens[0]==string("xx") ); + BOOST_CHECK( tokens[1]==string("xx") ); + + ifind_all( + tokens, + string("Xx-abc--xX-abb-xx"), + "xx" ); + + BOOST_REQUIRE( tokens.size()==3 ); + BOOST_CHECK( tokens[0]==string("Xx") ); + BOOST_CHECK( tokens[1]==string("xX") ); + BOOST_CHECK( tokens[2]==string("xx") ); +#endif + // split tests split( tokens, @@ -144,6 +168,21 @@ void iterator_test() BOOST_REQUIRE( tokens.size()==1 ); BOOST_CHECK( tokens[0]==string("") ); +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + // If using a compiler that supports forwarding references, we should be able to use rvalues, too + split( + tokens, + string("Xx-abc--xX-abb-xx"), + is_any_of("xX"), + token_compress_on ); + + BOOST_REQUIRE( tokens.size()==4 ); + BOOST_CHECK( tokens[0]==string("") ); + BOOST_CHECK( tokens[1]==string("-abc--") ); + BOOST_CHECK( tokens[2]==string("-abb-") ); + BOOST_CHECK( tokens[3]==string("") ); +#endif + find_iterator fiter=make_find_iterator(str1, first_finder("xx")); find_iterator fiter2;