草庐IT

ZN5boost

全部标签

c++ - 动态大小的 boost::asio::buffer

我正在像这样从boost::asio::ip::udp::socket读取数据:usingboost::asio::ip::udp;//...charrecv_buf[128];udp::endpointsender_endpoint;size_tlen=socket.receive_from(boost::asio::buffer(recv_buf),sender_endpoint);现在,这工作得很好,但我现在能够接收的最大字符数是127。但是我遇到了一个问题,因为我需要接受一些长度可能变化很大的数据输入(并且是例如,不是带有前缀header的明确定义的长度)。对此的解决方案是动态

c++ - 什么是 boost::asio::ssl::context::load_verify_file 以及如何使用它?

有少量的boost::asio::ssl在线小型C++教育代码库。在boost::asio::ssl::context::load_verify_file上就更少了所以我从here找到了一个修改最少的代码-使用boost1.47.0编译和运行:#include#include#include#include#include#include#includeclassclient{public:client(boost::asio::io_service&io_service,boost::asio::ssl::context&context,boost::asio::ip::tcp::r

c++ - 如何使用 Boost.program_options 检测拼写错误?

我使用boost.program_options库。考虑这个简化的案例。po::options_descriptiondesc("Usage");desc.add_options()("uninstall,u","uninstallprogram")("custom,c",po::wvalue(),"specifycustomaction");po::variables_mapvm;po::store(po::parse_command_line(argc,argv,desc),vm);po::notify(vm);我想在这样的命令行上产生错误:testprog.exe-uc-acti

c++ - (如何)我可以将 Boost 字符串算法库与 c 字符串(字符指针)一起使用?

是否有可能以某种方式调整c风格的字符串/缓冲区(char*或wchar_t*)以与BoostStringAlgorithmsLibrary一起工作??也就是说,例如,它的trim算法有如下声明:templatevoidtrim(SequenceT&,conststd::locale&=std::locale());和theimplementation(寻找trim_left_if)要求序列类型有一个成员函数erase。我如何将其与原始字符指针/c字符串缓冲区一起使用?char*pStr=getSomeCString();//example,couldalsobesomethinglik

c++ - 使用boost图形库: how to create a graph by reading edge lists from file

我是boost图形库的新手,我想通过从文件中读取边列表来创建图形。edge_list.dat文件的示例是这样的:...12344545353433432454123345123566...文件的每一行代表图中的一条边,每行中的两个数字是该边对应的节点id。现在我想使用boost图形库从文件edge_list.dat创建一个图形。但是,我事先并不知道图形的大小。我需要一路将顶点添加到图中。然而,像这样为每个顶点创建一个顶点描述符是不切实际的:Graph::vertex_descriptorv0=boost::add_vertex(g);Graph::vertex_descriptorv1

c++ - 我如何将多态属性与 boost::spirit::qi 解析器一起使用?

我希望我的基于boost::spirit的解析器能够解析文件,将解析的规则转换为不同的类型,并发出一个包含它找到的所有匹配项的vector。所有作为属性发出的类型都应该从基类型继承,例如:#include#include#include#includestructCommandBase{virtualvoidcommandAction(){std::coutvalueB;virtualvoidcommandAction(){std::coutlabelName;std::vector>commands;virtualvoidcommandAction(){std::coutc,comm

c++ - boost.graph 1.56.0 和 g++ 4.6.4 编译错误

在尝试使用Boost.Graph时遇到了一些严重的编译错误。该错误是回归,因为它在编译1.55.0时不存在。我已经挖了一点但无法修复它,有人知道这里出了什么问题吗?注意事项:使用-std=c++0x编译标志将产生错误的代码。#include"boost/graph/adjacency_list.hpp"intmain(intargc,char**argv){usingboost::adjacency_list;usingboost::vecS;usingboost::directedS;typedefadjacency_listGraph;std::vector>testVec;aut

c++ - boost : persistent storage of R-trees?

因此boost以R树的形式提供了很好的空间索引功能。这很好,但似乎还不可能在构建树后对其进行序列化,我错了吗?通常的“out_archive那么第一个问题:有人知道如何使用boost序列化R树吗?如果没有,那么我的第二个问题:您将如何将索引永久存储在磁盘上以避免每次都重建它?(我有一个包含145M条目的数据集,构建索引需要几个小时,所以我真的不想构建它不止一次!) 最佳答案 打包算法和批量加载可以加载包(使用打包算法)。AdditionallytherearealsoalgorithmscreatingR-treecontainin

c++ - 从给定的嵌套 boost-variant 类型创建一个新的 boost-variant 类型

假设我有一个嵌套的boost::variant-类型TNested包含一些类型和一些其他boost::variant类型(它本身不能再次包含boost::varianttypes,因此不会有递归)。我正在寻找模板别名flatten这将评估为boost::variant类型没有嵌套boost::variants,例如TFlatten,而可能的重复类型正在被删除,例如int只出现一次。我真的不知道这是否能以某种方式实现。#include#include#includestructPerson;typedefboost::variant,boost::variant>TNested;type

c++ - Clang 模块与 std <iterator> 和 <boost/move/iterator.hpp> 交互

(有关我正在使用的特定版本的Boost和Clang的信息,请参阅问题结尾)使用新的实验性-fmodules从master/HEAD在Clang中编译功能,使用如下所示的命令行选项编译以下文件时出现构建错误:#include#include编译命令及错误:anhall@leviathan:/bin/clang++-ofile.o-cfile.cpp--std=c++1z-stdlib=libc++-fmodulesInfileincludedfromfile.cpp:2:Infileincludedfrom/usr/local/include/boost/move/iterator.hp