boostorg / algorithm

Boost.org algorithm module
http://boost.org/libs/algorithm
Boost Software License 1.0
114 stars 105 forks source link

Use forwarding references in string/split.hpp #49

Closed BenHetherington closed 5 years ago

BenHetherington commented 6 years ago

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(" "));

I'm somewhat surprised that this hasn't been done before, so if I'm missing something, then do let me know. I've hardly done a comprehensive investigation on where else these changes could be made in boost::algorithm, so I'm also happy to expand this PR if necessary.

mclow commented 6 years ago

Tests?

BenHetherington commented 6 years ago

Whoops, looks like I saw the tests/ directory, but missed the string/tests/ directory, so I naïvely assumed there weren't any existing tests for split and co. I'll push some new lvalue tests now.

BenHetherington commented 6 years ago

Now that tests have been added, is there anything else you'd like me to do to advance this PR, @mclow?

BenHetherington commented 5 years ago

Sorry to bump this again, but it'd be really nice if this usability improvement could be merged at some point 🙂 If there's anything you'd like me to do to aid that, e.g. seeing where else this change could be helpful in boost::algorithm, or rebasing/squashing commits, then I'd be very happy to do so!

mclow commented 5 years ago

Just saw this tonight. I'll see if I can get to it this weekend.