更新时间:2022-11-17 10:24:55
在以下code,让我假设使用空间boost
为简洁。结果
至于对字符分割,如果只算法/串
是允许的, is_from_range
可能达到目的:
In the following code, let me assume using namespace boost
for brevity.
As for splitting on a character, if only algorithm/string
is allowed,
is_from_range
might serve the purpose:
split(vec,str, is_from_range(':',':'));
另外,被允许如果的λ
:
split(vec,str, lambda::_1 == ':');
如果preparing专用predicate是允许的:
or if preparing a dedicated predicate is allowed:
struct match_char {
char c;
match_char(char c) : c(c) {}
bool operator()(char x) const { return x == c; }
};
split(vec,str, match_char(':'));
至于对一个字符串匹配,为的大卫Rodri'guez 的提到,
那里似乎不是与拆分
的方式。
如果 iter_split
是允许的,可能是下面的code见面会的宗旨是:
As for matching against a string, as David Rodri'guez mentioned,
there seems not to be the way with split
.
If iter_split
is allowed, probably the following code will meet the purpose:
iter_split(vec,str, first_finder("::"));