使用 boost::split 会带来大量奇怪的错误
Using boost::split brings up a load of weird errors
#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>
。
相关文章:
- boost::进程间消息队列引发错误
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 在cygwin中测试新的boost安装时出现cpp错误
- 错误"Could not find Boost"(缺少:上下文标头)
- FindPackageHandleStandardArgs.cmake:137 的 CMake 错误(消息):找不到 Boost (缺少:正则表达式)(找到合适的版本"1.72.0",
- VS Code C++:不准确的系统包括路径错误(wchar.h,boost/lambda/lambda.hpp)
- 尝试将 boost::stacktrace 添加到 CMake 项目时出现构建错误
- 在 boost::qi 中使用过多的替代运算符会导致分段错误
- 使用boost::multiprecision cpp_int左移时出现超时错误
- 致命错误:找不到'boost/uuid/uuid.hpp'文件
- 造成致命错误:boost/fusion/iterator/equal_to.hpp 没有这样的文件或目录
- 编译器错误boost :: asio ::占位符:: boost v1.69的错误
- C++链接错误(Boost线程)
- 错误:“boost::array”不是一种类型
- 开始使用boost-cpu_timer时,错误:“boost::timer::cpu_timer”尚未声明
- 编译错误-boost::numeric::ublas::coordinate_matrix
- Boost错误:Boost.文件系统V3及更高版本需要std::wstring支持
- 错误boost::文件系统没有名为string()的成员
- 错误:BOOST禁用线程
- 链接错误Boost.使用stlport作为标准库的Python