草庐IT

boost-pool

全部标签

c++ - boost async_write 问题

我将展示一些代码;voidwh(constboost::system::error_code&ec,std::size_tbytes_transferred){std::cout当我使用该代码时出现内存泄漏,我发现一些代码(如minicom_client教程)甚至从该代码中变得复杂,而且我在minicom_client上出现内存泄漏。如果我使用boost::asio::write(pSerial,boost::asio::buffer("A",1));代替async_write效果很好,你能解释一下那里发生了什么吗,非常感谢...... 最佳答案

c++ - Visual Studio 2010 中的 boost::thread 编译错误

我在很长一段时间内第一次尝试使用boost,当我包含boost/thread.hppheader时,我在boost本身内部遇到编译错误:c:\myproj\boost_1_46_0\boost\thread\win32\thread_heap_alloc.hpp(97):errorC2061:syntaxerror:identifier'heap_memoryc:\myproj\boost_1_46_0\boost\thread\detail\thread.hpp(134):seereferencetofunctiontemplateinstantiation'T*boost::det

c++ - boost/ python : How can I use/convert extracted objects?

假设:usingnamespaceboost::python;voidmyClass::test(numeric::array&arrayParam){consttuple&shape=extract(arrayParam.attr("shape"));}例如,我想将其转换为int并进行打印。我尝试了intx=shape[0];但它给了我一条消息“无法在初始化中将‘boost::python::api::const_object_item’转换为‘int’”。 最佳答案 shape[0]为您提供一个Python对象。要将其转换为in

c++ - boost::ref 和 boost::asio 完成处理程序,按引用传递

m_io_service.post(boost::ref(i));我在一段代码中有这个调用,底层类型i绝对是一个可调用的(因为删除boost::ref导致按值传递,这工作正常),但是clang告诉我:/opt/dev_64_swat/proto-rpc2/dependencies/boost/include/boost/asio/handler_invoke_hook.hpp:64:3:error:type'boost::reference_wrapper'doesnotprovideacalloperator我如何通过引用传递,我有比异步调用生命周期更长的对象,如果我可以通过引用传递

c++ - boost::variant 是否与 std::string 一起使用?

我使用boost::variant用C++编写了一个简单的程序。程序代码如下所示。#include#include#includeintmain(intargc,char**argv){boost::variantv;v=3;std::cout但是当我尝试用命令编译它时g++main.cpp-omain-lboost_system我明白了/usr/include/boost/variant/detail/variant_io.hpp:64:error:nomatchfor‘operator>>*)this)->boost::detail::variant::printer>>::out

c++ - 将 boost::bind 与 boost::function 一起使用:检索绑定(bind)变量类型

有什么方法可以检索有关哪些参数受boost::bind限制的信息,还是需要手动存储?即:在.h中classMyClass{voidfoo(inta);voidfoo2(doubleb);voidbar();voidexecute();int_myint;double_mydouble;}在.cpp中MyClass::bar(){vectormyVector;myVector.push_back(boost::bind(&MyClass::foo,this,MyClass::_myint);myVector.push_back(boost::bind(&MyClass::foo2,thi

c++ - 如何格式化不带引号的 boost 路径对象?

这是我的代码:fs::pathdatadir=...;std::stringdataDirOption((boost::format("--datadir=%1%")%datadir).str());对于datadir=="c:/db",我得到dataDirOption=="--datadir=\"c:/db\"",而不是"--datadir=c:/db"是否可以告诉boost::filesystem::path在格式化时跳过引号?现在,我知道我可以用datadir.string()替换datadir并以这种方式去掉引号,但我想知道我是否可以这样做没有额外的字符串。谢谢。

c++ - 链接 boost::thread

我正在尝试使用boost库学习一些东西,但是当我尝试编译包含boost::threads的东西时遇到了问题。我在链接过程中遇到错误,消息如下:/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld:cannotfind-lboost-thread但这很奇怪,因为只有当我用普通用户编译时才会发生这种情况,使用root我可以毫无问题地编译。提前致谢。 最佳答案 包含#include其他链接器标志-lboost_system-lboost_

c++ - 将字符串 vector 连接到 std::ostream(如 boost::join)

我有一个字符串vector,我想将它输出到流(实际上是文件流)。我想在vector元素之间有一个分隔符。有一种方法可以使用标准ostream_iteratorstd::vectorstrs;std::ostream_iteratorout_file_iterator(out_file,delim);std::copy(strs.begin(),strs.end(),out_file_iterator);我不喜欢这种方式,因为each元素后有一个delim文本,但我不需要有一个delim在最后一个元素之后。我想使用类似boost::join的东西。但是boost::join返回字符串,而

c++ - Cpp - 检查 key 是否存在于 boost bimap 中

我有一张双图。我想检查key是否存在于我的bimap中。我怎样才能做到这一点。这是我的双图:namespacebimap{structName{};structID{};typedefboost::bimaps::bimap>,boost::bimaps::set_of>>name_index_bimap;}我想检查“名称”是否存在。 最佳答案 这在thisexample中解释得很清楚。.在您的情况下,它应该如下所示:name_index_mapyour_map;name_index_map::right_const_iterato