草庐IT

boosting

全部标签

c++ - 使用基于嵌套值的索引 boost 多索引容器

如果我有这样一个对象:structBar{std::stringconst&property();};我可以像这样为它创建一个多索引容器:structtag_prop{};typedefboost::multi_index_container,boost::multi_index::const_mem_fun>>,...otherindexes>BarContainer;但是如果我有这样一个类:structFoo{Barconst&bar();};如何为Foo对象的容器在.bar().property()上构建索引?通常我会嵌套调用boost::bind,但我不知道如何让它在多索引容器

c++ - 帮助理解 boost::bind 占位符参数

我正在阅读StackOverFlow上一篇关于按对的第二个元素对vector对进行排序的帖子。最明显的答案是创建一个谓词,但一个使用boost的答案引起了我的注意。std::sort(a.begin(),a.end(),boost::bind(&std::pair::second,_1)::second,_2));我一直在试图弄清楚boost::bind是如何工作的,或者至少只是如何使用它,但我无法弄清楚占位符参数_1和_2的目的是什么,以及boost文档根本不会陷进去。谁能解释一下boost::bind的具体用法?附言原题:HowdoIsortavectorofpairsbasedo

c++ - 在 gdb 上漂亮地打印 boost::unordered_map

最近我开始在我的系统上使用优秀的boost::unordered_map,但有一个缺点:我不知道如何检查它的内容。在gdb上打印它给了我一个table_和一个buckets_,但还没有找到项目在哪里。有人知道这件事吗? 最佳答案 对于那些想要打印机的人,我已经设法制造了一台。这是代码:classBoostUnorderedMapPrinter:"printsaboost::unordered_map"class_iterator:def__init__(self,fields):type_1=fields.val.type.temp

c++ - 使用 Boost 舍入到 C++ 中最接近的数字?

有没有办法在Boost库中四舍五入到最接近的数字?我指的是任何数字,2、5、17等等。或者有其他方法吗? 最佳答案 您可以使用C99中提供的lround。#include#includeintmain(){cout(输出1、2、2)。如果您需要和/或如何需要启用C99支持,请检查您的编译器文档。 关于c++-使用Boost舍入到C++中最接近的数字?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/q

c++ - 从 Boost 多索引迭代器获取数字索引

我正在存储以下内容structArticle{std::stringtitle;unsigneddb_id;//idfieldinMediaWikidatabasedump};在Boost.MultiIndex容器中,定义为typedefboost::multi_index_container,hashed_unique,member>,hashed_unique,member>>>ArticleSet;现在我有两个迭代器,一个来自index和一个来自index.在不向structArticle添加数据成员的情况下,将这些索引转换为容器的随机访问部分的最简单方法是什么??

c++ - 如何将 std::tuple 类型与 boost::mpl 算法一起使用?

boost::mpl算法似乎无法在开箱即用的std::tuple类型上工作,例如,以下不编译(boost-1.46.0,g++快照2011-02-19):#include#include#includenamespacempl=boost::mpl;typedefmpl::vectortypes;static_assert(mpl::contains::value,"vectorcontainsbool");typedefstd::tupletypes2;//thefollowingdoesnotcompile://error:noclasstemplatenamed‘apply’in

c++ - 添加 #include <boost/thread/mutex.hpp> 会破坏我的 ActiveX 控件吗?

在ActiveX控件中使用boost::mutexheader是否存在已知问题?(boost版v1.39)如果我在VisualStudio2008中创建一个名为“DefaultOCXControl”的MFCActiveX控件项目,那么我可以构建它,该控件将自身注册为构建的一部分,并且可以像您期望的那样插入到ActiveX测试容器中。一切顺利。如果我再添加这一行:#include在我的DefaultOCXControlCtrl.h文件顶部并重建:构建结束时的注册步骤失败并显示:DebugAssertionFailed!Program:C:\Windows\system32\regsvr3

c++ - 在 Boost::Program_Options 中,如何设置 wstring 的默认值?

我的下面的代码没有工作:wstringconfig_file;//Declareagroupofoptionsthatwillbe//allowedonlyoncommandlinepo::options_descriptiongeneric("Genericoptions");generic.add_options()("help,h","producehelpmessage")("config,c",po::wvalue(&config_file)->default_value(L"DXDrv.cfg"),"nameofafileofaconfiguration.");编译失败,错

c++ - Boost 1.53 本地日期时间编译器错误 -std=c++0x

使用g++版本4.7.2,如果我尝试编译以下内容#includeclassBar{public:Bar(){tz_db_.load_from_file("/home/date_time_zonespec.csv");}private:boost::local_time::tz_databasetz_db_;};intmain(){return0;}使用-std=c++0x我得到以下错误。Infileincludedfrom/usr/local/include/boost/date_time/local_time/local_time_types.hpp:18:0,from/usr/lo

c++ - BOOST ASIO POST HTTP REQUEST——标题和正文

几天来我一直在努力让它工作,但我一直从服务器收到400错误。基本上,我要做的是向服务器发送一个httpPOST请求,该请求需要一个具有几个属性的JSON请求正文。这些是我目前正在使用的库已更新---2013年7月23日上午10:00刚刚注意到我使用的是TCP而不是HTTP,不确定这会对HTTP调用产生多大影响,但我找不到任何使用带有BOOST的纯HTTP的客户端示例::ASIO#include#include#include#include#include#include#include#includeusingboost::property_tree::ptree;usingboos