Skip to content

Commit c6f784c

Browse files
committed
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(" "))
1 parent e4dfe08 commit c6f784c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

include/boost/algorithm/string/iter_find.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ namespace boost {
7171
inline SequenceSequenceT&
7272
iter_find(
7373
SequenceSequenceT& Result,
74+
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
75+
RangeT&& Input,
76+
#else
7477
RangeT& Input,
78+
#endif
7579
FinderT Finder )
7680
{
7781
BOOST_CONCEPT_ASSERT((
@@ -142,7 +146,11 @@ namespace boost {
142146
inline SequenceSequenceT&
143147
iter_split(
144148
SequenceSequenceT& Result,
149+
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
150+
RangeT&& Input,
151+
#else
145152
RangeT& Input,
153+
#endif
146154
FinderT Finder )
147155
{
148156
BOOST_CONCEPT_ASSERT((

include/boost/algorithm/string/split.hpp

+12
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ namespace boost {
6161
template< typename SequenceSequenceT, typename Range1T, typename Range2T >
6262
inline SequenceSequenceT& find_all(
6363
SequenceSequenceT& Result,
64+
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
65+
Range1T&& Input,
66+
#else
6467
Range1T& Input,
68+
#endif
6569
const Range2T& Search)
6670
{
6771
return ::boost::algorithm::iter_find(
@@ -96,7 +100,11 @@ namespace boost {
96100
template< typename SequenceSequenceT, typename Range1T, typename Range2T >
97101
inline SequenceSequenceT& ifind_all(
98102
SequenceSequenceT& Result,
103+
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
104+
Range1T&& Input,
105+
#else
99106
Range1T& Input,
107+
#endif
100108
const Range2T& Search,
101109
const std::locale& Loc=std::locale() )
102110
{
@@ -139,7 +147,11 @@ namespace boost {
139147
template< typename SequenceSequenceT, typename RangeT, typename PredicateT >
140148
inline SequenceSequenceT& split(
141149
SequenceSequenceT& Result,
150+
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
151+
RangeT&& Input,
152+
#else
142153
RangeT& Input,
154+
#endif
143155
PredicateT Pred,
144156
token_compress_mode_type eCompress=token_compress_off )
145157
{

0 commit comments

Comments
 (0)