使用 boost::split 会带来大量奇怪的错误

Using boost::split brings up a load of weird errors

本文关键字:错误 boost split 使用      更新时间:2023-10-16
#include <string>
#include "boostdate_timegregoriangregorian.hpp"
#include <boostalgorithmstring.hpp>
using namespace std;
using namespace boost::gregorian;
using namespace boost;

void printString()
{
vector<string> strs;
boost::split(strs, "string to split", boost::is_any_of(' '));
cout << strs[0];
}

这标记了 Boost 中的大约 6 个错误和 std 中的 1 个错误。我的想法是命名空间搞砸了。这是实际代码库的编辑版本,但基本上我使用 boost::gregorian 作为单独的date_time事物,并使用 boost 用于 algoritm 代码库。我看到了一个例子,使用多个命名空间很好。对我来说,它只是不允许我使用拆分。

您正在将单个字符传递给boost::is_any_of,但它需要一个序列。

将代码从:从: boost::is_any_of(' ')到:boost::is_any_of(" "),你应该是金色的。

(哦,是的,并在您的示例中添加#include <vector>#include <iostream>