草庐IT

boost-program-options

全部标签

c++ - boost spirit qi 整数和 float 的数值解析

我正在尝试理解以下结果。测试用例代码为#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#includenamespacesp=boost::spirit;namespaceqi=boost::spirit::qi;usingnamespaceboost::spirit::ascii;namespacefusion=boost::fusion;namespacephoenix=boost::phoe

c++ - 使用 BOOST_FOREACH 时如何测试 vector 中的最后一个元素?

我有一个迭代vector。vector的最后一个元素是特例,我想单独测试一下。例如,我可能会这样做:for(iterator=vector.begin();iterator!=vector.end();++iterator){if((iterator+1)==(vector.end())){...}else{...}}我想用BOOST_FOREACH宏替换迭代器。是否可以对最终元素进行类似的测试? 最佳答案 if(!vec.empty()){BOOST_FOREACH(inte,boost::make_iterator_range(

c++ - Qt 是否有与 Boost 的分配模块等效的东西?

在Boost中,有一些方便的函数可以让您在一行中填充一个容器。例如,list_of让你像这样填写一个列表。#include//for'list_of()'#includestd::listprimes=boost::assign::list_of(2)(3)(5)(7)(11);在我的项目中,我使用的是Qt,无法使用Boost。是否有类似方便的方法在构建时填充Qt的容器? 最佳答案 您可以使用QList::operatorQListprimes=QList() 关于c++-Qt是否有与B

c++ - 使用 Boost.MPI 库的目的是什么?

使用Boost.MPI库的目的是什么?它会boost性能吗?它和MPICH库有什么区别? 最佳答案 Boost.MPIprovidesanalternativeC++interfacetoMPIthatbettersupportsmodernC++developmentstyles,includingcompletesupportforuser-defineddatatypesandC++StandardLibrarytypes,arbitraryfunctionobjectsforcollectivealgorithms,andt

c++ - boost :什么是 "convenience header"?

boost中的“header”和“convenienceheader”有什么区别? 最佳答案 便利header通常(不仅仅是在Boost中)是一个包含许多其他header(包含实际代码)的header,这些header通常一起使用,即使它们之间没有硬依赖关系(这就是为什么它们'首先重新分开)。 关于c++-boost:什么是"convenienceheader"?,我们在StackOverflow上找到一个类似的问题: https://stackoverflo

c++ - 将 Google Mock 与 boost::bind 结合使用

我有一个类,其构造函数采用Boost函数,我想使用GoogleMock对其进行测试。以下代码显示了一个示例类以及我对其进行测试的尝试:我的类.h:#includeclassMyClass{public:MyClass(boost::functioncallback);voidcallCallback();private:boost::functionm_callback;};MyClassTest.cpp:#include#include#include#include"MyClass.h"classCallbackMock{public:MOCK_METHOD0(callback,v

c++ - 复制 boost::shared_ptr

typedefboost::shared_ptrdata_ptr;data_ptrcached_ptr;//classmemberboolsomeWork(data_ptr&passed_ptr){//mustcopypassed_ptr=cached_ptrundersomeconditions//withoutpointingatthesamememory//IsawsomewherethatIshoulddo//passed_ptr.reset(newSomeData(???))//Idon'thavea"reset"onpassed_ptr}我查看了文档;复制和转换构造函数sh

c++ - 如何在 OSX 中安装 boost C++ 库

我下载了boostjam并将其放入安装文件中并尝试运行它,显示以下错误:error:error:noJamfileincurrentdirectoryfound,andnotargetreferencesspecified. 最佳答案 更现代的包管理器homebrew用一个做这个$brewinstallboost 关于c++-如何在OSX中安装boostC++库,我们在StackOverflow上找到一个类似的问题: https://stackoverflow

c++ - 手动递增和递减 boost::shared_ptr?

有没有办法在C++中手动增加和减少shared_ptr的计数?我要解决的问题如下。我正在用C++编写一个库,但接口(interface)必须是纯C语言。在内部,我想使用shared_ptr来简化内存管理,同时保留通过C接口(interface)传递原始指针的能力。当我通过接口(interface)传递原始指针时,我想增加引用计数。然后客户端将负责调用一个函数,该函数将在不再需要传递的对象时减少引用计数。 最佳答案 也许您正在跨DLL边界使用boost::shared_ptr,这将无法正常工作。在这种情况下boost::intrusi

c++ - boost 精简版?

我听说有一个简单的boost实现,其中只有智能指针和一些其他非常基本的东西。我想我听说它也不使用任何操作系统功能。我试着寻找它,但一无所获。有谁知道它叫什么或不需要操作系统调用的boost型智能指针的实现? 最佳答案 您可以使用bcp,但请记住,使用Boost库只会让您为使用的内容付费-智能指针都是以仅header方式实现的,这意味着没有操作系统调用,没有要链接到的编译库等。因此,如果您不分发源代码,您可以下载完整的boost集,并仅使用您需要的位,而不会给您的应用程序带来任何(未被要求的)麻烦。