草庐IT

Boost-asio

全部标签

c++ - 如何在 Boost multi_index 复合键中删除?

我正在检查这个Boostmulti_indexcompositekeysusingMEM_FUN谁能告诉我如何为这个例子实现删除功能?现在我在做Name_set_by_last::iteratormitchells=names.get().find("mitchell");names.erase(mitchells);//showserror 最佳答案 names.get().erase(mitchells); 关于c++-如何在Boostmulti_index复合键中删除?,我们在St

c++ - 使用 boost 文件系统对文件进行排序

这是我的问题:我得到了一堆文件,这些文件的名称类似于“_X1.bla.txt”、“_X101.bla.txt”、_X47.bla.txt,我用boost::filesystem读入这些文件,添加到std::vector。正如您从示例中看到的,名称不以数字开头。在这个例子中,结果应该是1、47、101。如果你告诉我如何从文件中提取数字,我应该能够自己对文件进行自动排序。最佳胡岛 最佳答案 如果容器中有所有名称(类似于std::vector文件名),您可以这样做std::sort(filenames.begin(),filenames.

c++ - 用源代码 boost spirit 解析

我希望能够解析数字,存储其原始来源并跟踪其在来源中的位置,将其保存在结构本身中。这是我目前所拥有的:#include#include#include#include#include#include#include#include#include#include#include#include#include#include#includestructPosition{Position():line(-1){}size_tline;};structNumber:publicPosition{Number():Position(),value(-1),source(){}unsignedv

c++ - 如何从 boost::property_tree 获取枚举?

如何从boost::property_tree中获取枚举?这是我的“非工作”示例。配置文件EMISSION::EMIT142main.cpp#include#include#includeintmain(){enumclassEMISSION{EMIT1,EMIT2};enumEMISSIONmyEmission;//InitializetheXMLfileintoproperty_treeboost::property_tree::ptreept;read_xml("config.xml",pt);//testenum(SUCCESS)myEmission=EMISSION::EMI

c++ - Boost 变体 apply_visitor 编译错误

boost::variant和boost::apply_visitor的简单示例代码:#includestructExprFalse;structExprTrue;structExprMaybe;typedefboost::variantExpression;structExprFalse{};structExprTrue{};structExprMaybe{};structPrinter:publicboost::static_visitor{public:Printer(std::ostream&os):m_os(os){}voidoperator()(ExprFalseconst

c++ - boost 多边形序列化 : Ring

根据这个相关问题(BoostPolygonSerialization)。我正在尝试使用Boost序列化多边形。我现在遇到的问题是,我正在尝试使用自定义X、Y、点的多边形来编译示例,但编译器在编译时抛出此错误:error:'classboost::geometry::model::ring>'hasnomembernamed'serialize'就像没有定义任何函数来序列化一个环。由于Ring从std::vector扩展,并且如相关问题中所述,因此没有必要为其序列化定义方法。但是编译器会提示。这里有一个关于定义多边形及其序列化的完整示例:#include#include#include#

c++ - 将 Boost 序列化与 xml_oarchive 一起使用时 assertion_failed

在编译BoostSerialization的简单测试时:classTest{protected:intNum;friendclassboost::serialization::access;templatevoidserialize(Archive&ar,constunsignedintversion){ar&BOOST_SERIALIZATION_NVP(Num);}public:Test():Num(0){}~Test(){}};使用xml_oarchive进行输出,我遇到以下GCC错误:C:\Development\Libraries\boost_1_55_0\boost\mpl

c++ - 在 boost::posix_time 中设置值(年、月、日...)

在一个类中,我有一个属性boost::posix_time::ptime,它指的是这样的日期和时间:boost::posix_time::ptimep_;在构造函数中,我可以毫无问题地传递值和设置它们。my_class::my_class(...):p_(boost::posix_time::ptime(boost::gregorian::date(y,M,d),hours(h)+minutes(m)+seconds(s)+milliseconds(ms)+microseconds(us)+nanosec(ns));我想为这个ptime的所有字段(年、月、日、小时......如果可能的

c++ - 为什么 boost uniform_int_distribution 采用封闭范围(而不是半开放范围,遵循常见的 C++ 用法)?

标题说明了一切。甚至还有一个warning在文档页面中:Warning:ContrarytocommonC++usageuniform_int_distributiondoesnottakeahalf-openrange.Insteadittakesaclosedrange.Giventheparameters1and6,uniform_int_distributioncancanproduceanyofthevalues1,2,3,4,5,or6.当C++中的常见做法是使用开放范围[begin,end)时,为什么要这样做? 最佳答案

如何在课堂中正确使用Boost通道(和纤维)?

我正在尝试在课堂上使用Boost频道和纤维。这是一个简单的测试用例工作正常但这并不是我想要的。如果我移动”线:1“至”LOC:1“程序悬挂(GDB在c->push(a)之后的boost::纤维内的一个旋转锁显示。任何人都可以通过指向我做错了什么来帮助我吗?谢谢。这是有效并生成以下的示例代码,#include#includeusingnamespacestd;templateclassBlock{private:typedefboost::fibers::buffered_channelchannel_t;typedefboost::fibers::fiberfiber_t;fiber_t