This PR adds a simple string split helper SplitString
that takes use of the spanparsing Split
function that was first introduced in #13697 (commit fe8a7dcd78cfeedc9a7c705e91384f793822912b). This enables to replace most calls to boost::split
, in the cases where only a single separator character is used. Note that while previous attempts to replace boost::split
were controversial (e.g. #13751), this one has a trivial implementation: it merely uses an internal helper (that is unit tested and in regular use with output descriptiors) and converts its result from spans to strings. As a drawback though, not all boost::split
instances can be tackled.
As a possible optimization, one could return a vector of std::string_view
s (available since C++17) instead of strings, to avoid copies. This would need more carefulness on the caller sites though, to avoid potential lifetime issues, and it’s probably not worth it, considering that none of the places where strings are split are really performance-critical.