草庐IT

boost-iterators

全部标签

c++ - boost::python 函数调用中 boost::shared_ptr 的转换

考虑以下示例:#include"Python.h"#include#includeclassA{};classB:publicA{};voidfoo(boost::shared_ptr&aptr){}BOOST_PYTHON_MODULE(mypy){usingnamespaceboost::python;class_>("A",init());class_,bases>("B",init());def("foo",foo);}如果我调用python代码importmypyb=mypy.B()mypy.foo(b)我明白了ArgumentError:Pythonargumenttype

c++ - boost asio async_read_some 只读取数据片段

我有一个使用boost::asio进行读/写操作的C++服务器-写出消息工作正常-但由于某种原因我无法读取工作我从客户端发送给它的消息是1516位无符号短裤-我的测试消息是这样的:1,34,7,0,0,0,0,0,4,0,0,0,0,0,0现在在服务器上我经常看到这样的事情。读取通常被分解和/或乘以256这是一次发送两次readinglength=8:[134700000]readinglength=3:[102400]readinglength=3:[000]readinglength=8:[134700000]readinglength=6:[102400000]这是第二次发送两次

c++ - 使用 Boost 的 C++ 中的多线程之谜

staticvoidtestlock(){for(inti=0;ithreads;for(intj=0;jjoin();deletethreads[j];}cout输出:Starttesting1threads:1800002threads:3500003threads:5400004threads:7300005threads:9000006threads:10800007threads:12600008threads:15100009threads:166000010threads:1810000我在四核PC(Core2Quad,4核无超线程)上运行此代码,因此我预计1-4个线程会

c++ - std::wostream_iterator

为什么C++中没有std::wostream_iterator?这有什么好的理由吗?#include#include#include#includeintmain(){std::vectormyvec={L"first",L"second"};std::wofstreamf("New.txt");//std::copy(myvec.begin(),myvec.end(),std::wostream_iterator(f));//Error//std::copy(myvec.begin(),myvec.end(),std::ostream_iterator(f));//Errorstd:

c++ - 使用带有 Boost ASIO 的 UDP 的文件套接字 I/O

所以我尝试在我的FreeBSD服务器上使用boost.log和系统日志接收器,它运行rsyslogd并在文件套接字上监听UDP数据。显然这适用于FreeBSD领域。事实上,文件套接字是一个dgram套接字(telnet到文件套接字是在FreeBSD中工作的另一件事):$telnet/var/run/logTrying/var/run/log.../var/run/log:Protocolwrongtypeforsocket无论如何,boost.log不会与文件套接字通信,只会与IP地址通信。我的计划是在我的应用程序中继到文件套接字的常规基于IP的UDP服务器之间代理信息。从理论上讲,这

c++ - 我如何 grok boost spirit 编译器错误

我正在尝试使用no_skip指令来解析表单的输入:statePASSstateFAIL我正在使用ascii::blank作为我的skipper。当我包装no_skip[trans_assign_expr]以解析选项卡时,出现编译错误。如何修复此错误,一般而言,我如何理解这些错误以便修复future的错误?boostspirit文档从不涉及使用spirit的这方面:(这是错误Infileincludedfrom/usr/include/boost/spirit/home/qi/nonterminal/grammar.hpp:18:0,from/usr/include/boost/spir

c++ - 当类包含 boost::container::flat_set 时复制对象时出错

根据(错误的?)印象,boost::container::flat_set是std::set的直接替代品,我更换了set与flat_set在任何我期望元素数量较少且搜索性能比插入更重要的地方。在稍后阶段,我被一个令人困惑的编译错误难住了,我最终追查到使用flat_set作为类成员。例如:classRoom{private:boost::container::flat_setv;};下面的代码不会编译,但如果我用std::set替换flat_set就可以正常工作。Rooma;Roomb=Room();//Example1.CompilesOKa=b;//Example2.Compiles

c# - 是否有相当于 C# TryParse 的 boost lexical_cast?

简介(来自EricLippert博客):Vexingexceptionsaretheresultofunfortunatedesigndecisions.Vexingexceptionsarethrowninacompletelynon-exceptionalcircumstance,andthereforemustbecaughtandhandledallthetime.TheclassicexampleofavexingexceptionisInt32.Parse,whichthrowsifyougiveitastringthatcannotbeparsedasaninteger.

c++ - forward_list::splice_after( const_iterator pos, forward_list& other, const_iterator i ) 功能

我正在阅读有关此功能工作方式的不同解释。cplusplus.com说这个函数应该“直接在i之后移动元素”。然而cppreference.com表示它拼接元素ATi。MSvisualstudio同意cplusplus.com。但是,实际上正确的行为是什么?我倾向于认为“在i之后”移动更合乎逻辑(&不需要N时间来找到前面的节点)。(PS:没有forward-list标签?) 最佳答案 23.3.4.6voidsplice_after(const_iteratorposition,forward_list&x,const_iterator

c++ - boost ptr_map 替换值

给定一个键,我试图替换一个值。对于不使用指针的常规映射,我只是使用了以下调用iter->second=object;//Whereobjectwaspassedinbyreference如何使用boost::ptr_map实现同样的效果?这里的概念是我们用derived_object替换整个类iter->second=derived_object;//derived_objectisabase_objectpointer 最佳答案 这样就可以了:the_map.replace(iter,derived_object);当然在哪里,t