草庐IT

boost_thread

全部标签

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++ - 即使在 num_threads(1) 时,openmp 的性能提升也难以理解

下面几行代码intnrows=4096;intncols=4096;size_tnumel=nrows*ncols;unsignedchar*buff=(unsignedchar*)malloc(numel);unsignedchar*pbuff=buff;#pragmaompparallelforschedule(static),firstprivate(pbuff,nrows,ncols),num_threads(1)for(inti=0;i编译时需要11130usecs在我的i5-3230M上运行g++-omainmain.cpp-std=c++0x-O3也就是说,当openmp

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