gpt4 book ai didi

c++ - 为什么在使用 boost::split 时必须使用 boost::is_any_of?

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:08:23 26 4
gpt4 key购买 nike

为什么在使用 boost::split 时必须使用 boost::is_any_of ?

当我使用:boost::split(split_res, someStr, ".");

我得到一个错误。

最佳答案

Why?

因为 API 就是这样设计的(例如,它允许动态谓词考虑语言环境等因素)。

But how could I know? I got a weird error

您可以阅读 documentation .如果您使用不当,编译器会告诉您。

This seems too complicated for me

不要使用它。将其包装在一个具有您喜欢的更简单界面的函数中。

Live On Coliru

namespace my {
template <typename R = std::vector<std::string> >
R split(std::string const& input, char delim = '.') {
R v;
boost::split(v, input, boost::algorithm::is_any_of(std::array<char,1>{delim}));
return v;
}
}

关于c++ - 为什么在使用 boost::split 时必须使用 boost::is_any_of?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46013189/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com