草庐IT

boost-coroutine

全部标签

c++ - 如何在 boost::transform_iterator 中使用 phoenix 表达式?

和往常一样,这个问题是错误的。实际问题是:为什么transform_iterator不使用传统的result_of元函数来确定返回类型,而是直接访问UnaryFunc::result_type。发布了一个解决方法的答案。具体来说,是否有办法使phoenix表达式按照std::unary_function概念的预期公开result_type类型?boost::transform_iterator似乎预料到了这一点,从它的src来看,我没有看到一个简单的解决方法。下面是一些重现我遇到的问题的代码:#include#include#include#includeusingnamespaceb

c++ - 如何测量共享内存中 boost 进程间 vector 的大小?

我正在使用boost::interprocess::vector在进程之间共享一些字符串,我想确保我不会溢出它所在的共享内存段。我如何找到vector在内存中占用多少空间,以及一个特殊的段分配字符串将占用多少内存?typedefboost::interprocess::managed_shared_memory::segment_managerSegmentManager;typedefboost::interprocess::allocatorCharAllocator;typedefboost::interprocess::basic_string,CharAllocator>Sh

c++ - BOOST_CHECK_EQUAL(和衍生品)添加自定义消息

我们最近开始使用BoostTest框架,到目前为止很喜欢它。但是,在某些测试中,如果我们可以将自定义消息添加到现有帮助程序,那将会很棒。例如,我可以在mytest和mytest2中获取输出,但在mytest3中找不到输出:#defineBOOST_TEST_MODULEmytests#includeBOOST_AUTO_TEST_SUITE(myunit)BOOST_AUTO_TEST_CASE(mytest){//Thisgiveaniceoutput[2+2!=5]BOOST_CHECK_EQUAL(2+2,5);}BOOST_AUTO_TEST_CASE(mytest2){//T

c++ - 如何使用 boost::asio 连接到 unix 域套接字?

我想通过指定套接字端点的路径名来创建并连接到SOCK_SEQPACKET类型的unix域套接字,但这无法在中编译boost::asiov1.60:usingnamespaceboost::asio::generic;seq_packet_protocolproto{AF_UNIX,IPPROTO_SCTP};//SOCK_SEQPACKETseq_packet_protocol::socketsock(io_service,proto);boost::asio::local::basic_endpointep("/tmp/socket");sock.connect(ep);//does

c++ - 使用模板类 boost python

我创建了一个环形缓冲区,我想使用boost将该类导入Python。当我尝试这样做时,它会出错。ring.cpp:Infunction‘voidinit_module_ring()’:ring.cpp:130:16:error:wrongnumberoftemplatearguments(1,shouldbe4)class_("Ring").Pleasehelpme.ThanksinAdvance.这是我的代码:#include#includeusingnamespacestd;usingnamespaceboost::python;templateclassRing{public:cl

c++ - 使用 boost::property_tree::ptree 将注释写入 ini 文件

有什么方法可以使用boost::property::ptree在ini文件中写入注释吗?类似的东西:voidsave_ini(conststd::string&path){boost::property_tree::ptreept;intfirst_value=1;intsecond_value=2;//Writeacommenttodescribewhatthefirst_valueisherept.put("something.first_value",);//Writeasecondcommentherept.put("something.second_value",second

c++ - 检查类型是否可以作为 boost::lexical_cast<string> 的参数

我有以下特征类(IsLexCastable)来检查是否可以通过调用boost::lexical_cast将类型转换为字符串.它错误地返回true对于vector.#include#include#include#include#include#includeusingnamespacestd;usingnamespaceboost;namespacestd{///AddingtostdsincethesearegoingtobepartofitinC++14.templateusingenable_if_t=typenamestd::enable_if::type;}templates

C++ 如何在 Boost Global Logger 上设置严重性过滤器

几天来我一直在尝试创建一个BoostGlobalLogger以在整个应用程序中使用但我似乎无法在GlobalLogger中设置严重性级别。重要提示:在下面查看Andrey的回答...它被标记为步骤(a)和(b),但我仍然没有做对!直接来自Boost文档here...itwouldbemoreconvenienttohaveoneorseveralgloballoggersinordertoeasilyaccessthemineveryplacewhenneeded.Inthisregardstd::coutisagoodexampleofsuchalogger.Thelibrarypr

c++ - Boost any_range 与 "canonical form"- 后者是什么?

Boost的any_range文档说明如下:Despitetheunderlyingany_iteratorbeingthefastestavailableimplementation,theperformanceoverheadofany_rangeisstillappreciableduetothecostofvirtualfunctioncallsrequiredtoimplementincrement,decrement,advance,equaletc.Frequentlyabetterdesignchoiceistoconverttoacanonicalform.作者所说的

c++ - boost::make_shared 导致访问冲突

我有一个用于ARMV4IWindowsMobile6的VisualStudio2008C++应用程序,我正在使用boost::shared_ptr管理一个相当大的对象(4KB)。不幸的是,boost::make_shared导致访问冲突异常。我的代码:structFoo{chara[4*1024-1];};int_tmain(intargc,_TCHAR*argv[]){boost::shared_ptrf=boost::make_shared();//AccessViolationreturn0;}异常调用栈:test.exe!boost::detail::sp_ms_deleter