使用boost ::分裂带来了奇怪的错误的负载 [英] Using boost::split brings up a load of weird errors

查看:298
本文介绍了使用boost ::分裂带来了奇怪的错误的负载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <string>
#include "boost\date_time\gregorian\gregorian.hpp"
#include <boost\algorithm\string.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];
}

这标志了在升压6错误和性病1。我的想法是对的命名空间搞乱。这是实际code基的编辑版本,但基本上我使用boost ::公历为一个单独的date_time的事情,提振了algoritm code基地。我看到了一个例子,并使用多个命名空间的罚款。对我来说,只是没有让我使用分裂。

This flags up about 6 errors in Boost and 1 in std. My thinking is the namespaces are messing up. This is an edited version of the actual code base but basically I'm using boost::gregorian for a seperate date_time thing and boost for the algoritm code base. I saw an example and using more than one namespace was fine. For me it's just not letting me use split.

推荐答案

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

You're passing a single character to boost::is_any_of, but it expects a sequence.

更改从code:
来自:的boost :: is_any_of('')
于:的boost :: is_any_of(),你应该是金色的。

Change the code from: from: boost::is_any_of(' ') to: boost::is_any_of(" ") and you should be golden.

(噢,并添加的#include&LT;载体&GT; 的#include&LT; iostream的&GT; 您例子。

(oh yeah, and add #include <vector> and #include <iostream> to your example.

这篇关于使用boost ::分裂带来了奇怪的错误的负载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆