是否有split_copy或某种捷径

问题描述 投票:1回答:1

有没有人知道的boost::split一条捷径。那

std::vector<std::string> args;
boost::split(args, argsString, boost::is_any_of("\t "), boost::token_compress_on);

auto const args = boost::split(args, argsString, boost::is_any_of("\t "), boost::token_compress_on);
or
auto const args = boost::split<std::vector>(args, argsString, boost::is_any_of("\t "), boost::token_compress_on);

基本上是相同的像有,例如,一个用于trim - trim_copy

c++ boost
1个回答
1
投票

没有快捷方式在升压存在,据我所知。就个人而言,我写了一个简单的包装为split因为我有同样的问题,它是你做的:

template <typename RangeT, typename PredicateT>
std::vector<std::string> split(RangeT& Input, PredicateT Pred, 
                               boost::algorithm::token_compress_mode_type eCompress = boost::token_compress_off)
{
   std::vector<std::string> toReturn;
   boost::split(toReturn, Input, Pred, eCompress);
   return toReturn;
}

Demo

© www.soinside.com 2019 - 2024. All rights reserved.