草庐IT

boosting

全部标签

c++ - 使用指针和非默认构造函数 boost 序列化

您将如何使用boost::serialization序列化/反序列化此类?#includestructFoo{structBar{std::vector*data;//MustpointtoFoo::dataBar(std::vector*d):data(d){}};std::vectordata;std::vectorelements;Foo(){//doverytimeconsumingcalculationtopopulate"data"and"elements"}};当从序列化数据加载对象时,不得执行Foo中的构造函数,但如果对象是默认构造的,则必须评估构造函数。给Bar添加默

c++ - 派生对象的 boost 序列化不调用派生的序列化()

我已经阅读了大量类似的问题,但没有找到答案。我正在使用VisualStudio2010和boost1.47。这是完整的可编译代码:#include"stdafx.h"#include#include#include#include#includeusingnamespacestd;classBaseObject{public:BaseObject(void){};virtual~BaseObject(void){};templatevoidserialize(Archive&ar,constunsignedintversion){/*nothinghappenshere*/};};cl

c++ - 使用 boost 库收听 udp 广播

这似乎是很多人都有的问题,但到目前为止我找到的所有答案都没有帮助。问题:我正在尝试收听通过UDP将其数据包发送到我的电脑的VelodyneHDL32。操作系统为32位Ubuntu和Boost库v1.46。我通过Wireshark获取的数据如下所示:Time|Source|Destination|Protocol|Length|SourcePort|DestinationPort0.000000|192.168.17.212|192.168.3.255|UDP|1248|https|opentable但是使用这段代码,没有数据显示给我(端口是正确的):receiver(boost::as

c++ - Boost.Phoenix 是否天生就比等效的 C++11 lambda 慢(它是否使用虚拟调用、 'volatile' 用法等)?

我一直认为Boost.Phoenix使用类型推断来静态推断所有内容,直到我尝试了这段代码:#include#includeusingnamespaceboost::phoenix;usingnamespaceboost::phoenix::placeholders;structFoo{intx;};intmain(){std::vectorbar;bind(&Foo::x,ref(bar)[_1])("invalidindex");//oopsreturn0;}并得到警告:warningC4239:nonstandardextensionused:'argument':conversi

c++ - 在执行 DFS 时在 Boost::graph 中维护迭代器

Boost:graph库的大多数示例通过调用boost的深度优先搜索实用程序来执行深度优先搜索。创建顶点和边后,在图上调用DFS以深度优先的方式遍历整个图,如果我们有与之关联的访问者方法,它将调用访问者方法来执行操作,遍历每个节点。我正在寻找的是一种在图上维护迭代器的方法,而不是一次遍历图,当客户端调用“next()”时,迭代器将移动到下一个顶点遍历到DFS并再次调用next时,迭代器将移动到DFS指示的下一个顶点。是否有使用boost:graph执行上述操作的示例?谢谢 最佳答案 不幸的是,boost::graphAPI基于访问者

c++ - 如何用 "-pthread"而不是 "-mthread"编译 boost_thread?

我有一个操作系统,编译时没有可用的-mthread。我有-pthread。如何用-pthread而不是-mthread编译boost_thread?我当前的编译器构建日志:./b2-j1--with-threadlink=static--prefix=./install-dirreleasethreading=multi--builddir=./build-dirinstallComponentconfiguration:-chrono:notbuilding-context:notbuilding-date_time:notbuilding-exception:notbuilding

c++ - Boost.Serialization 会直接与虚拟菱形继承(钻石问题)一起工作吗?

我是第一次看Boost.Serialization,我找不到关于虚拟菱形继承(钻石问题)结构序列化的明确评估(或说明)。考虑以下类层次结构:classA{inta;}classB1:publicvirtualA{intb1;}classB2:publicvirtualA{intb2;}classB3:publicvirtualA{intb3;}classC12:publicvirtualB1,publicvirtualB2{intc12;}classC13:publicvirtualB1,publicvirtualB3{intc13;}classC23:publicvirtualB2,

c++ - 如何正确链接 boost::mpl::inherit_linearly 和 boost::mpl::inherit 以便解析占位符?

假设我有这些类型:templateclassStorage>structAbstractFactoryUnit{virtual~AbstractFactoryUnit(){}virtualtypenameStorage::StoredTypedoCreate(Storage)=0;};和templateclassProductStorage,templateclass>classUnit=AbstractFactoryUnit>structAbstractFactory:boost::mpl::inherit_linearly>>::type{typedefTypeSequencePr

c++ - Boost协程断言失败

为了在boost中尝试新的协程功能,我创建了以下程序:#include#include#includetypedefboost::coroutines::coroutinecoroutine_t;voidf(coroutine_t::caller_type&ca){std::vectorvec={1,2,3};for(inti:vec){charc=ca.get();std::cout代码基于samplecodefromthedocs.我的构建命令如下:$g++-std=c++11-otest-I/usr/local/include-L/usr/local/libmain.cpp/us

c++ - `boost::signals2` 中的信号签名是如何实现的?

我在我的项目中使用boost::signals2已有一段时间了。令我遗憾的是,我仍然不明白它们是如何在幕后实现的。我的问题已经从信号的定义开始了。如何定义如boost::signals2::signal处理了吗?我可以从实现细节中看出,签名变成了一个模板参数,它被恰本地命名为Signature。但是,我不明白语法。C++标准是否允许这种语法?以这种形式提供的信号如何“存储”函数签名?我已经尝试查看源代码,但无法找到此语法的解释。任何帮助将不胜感激。 最佳答案 是的,这种语法是允许的;它表示的类型是一个对采用bool和double并返