草庐IT

c++ - boost::interprocess::basic_string 作为 std::string

我正在尝试用constboost::interprocess::basic_string&替换返回conststd::string&的类方法。我面临的主要挑战是这两个类之间的不兼容性,尽管它们的实现相似。为了更清楚的解释,我将把它放入代码中classA{std::stringm_str;conststd::string&StrVal(){returnm_str;}}现在这个类看起来像这样:typedefboost::interprocess::allocatorShmemAllocatorChar;typedefboost::interprocess::basic_string,Shm

c++ - boost 测试库: Multiple definition error

我正在尝试在QTCreatorforWindows中测试我完成的库(微积分)。我已经创建了一个主文件,并在单独的文件中创建了一个类用于测试。如果我编译在http://www.boost.org/doc/libs/1_47_0/libs/test/doc/html/utf/user-guide/test-organization/manual-test-suite.html中找到的示例它有效,所以在http://www.boost.org/doc/libs/1_47_0/libs/test/doc/html/utf/user-guide/test-organization/manual-

c++ - 文件 basic_socket.hpp 中的 lib boost asio 1.47.0 出错

当我尝试编译时,以下代码出现错误:voidServer::accept(void){Network::ptrconnection=Network::initialize(this->my_acceptor.get_io_service());this->my_acceptor.async_accept(connection->socket(),bind(&Server::endCmd,this,*connection,placeholders::error));}voidServer::endCmd(Networkconnection,constboost::system::error

c++ - 使用 Boost.GIL 将图像转换为 "raw"字节

目标我正在尝试转向BoostGIL以替换我已经实现的一些类似功能,这些功能已达到其可维护生命的终点。我现有的代码可以使用uint8_t*处理24BPP、8位RGB图像.我无法更改它,因为相同的接口(interface)用于显示来自不同位置(例如OpenGL缓冲区)的图像,并且已经有相当多的代码。因此,我尝试逐步使用GIL,首先读取文件并将像素逐字节复制到std::vector中我可以用它来管理存储,但仍然得到uint8_t*通过使用&vector[0].这可以透明地放在现有接口(interface)后面,直到重构有意义为止。我尝试过的我认为这应该是使用copy_pixels()的简单案

c++ - 如何找出 nviews vector 的返回类型

我有以下问题:template/*whatisthereturntype*/nviewgetter(Tconst&t){typenameT::const_iteratorit(t.begin());typedefBOOST_TYPEOF_TPL(*it)etype;typedeftypenameboost::fusion::result_of::as_nview::typenetype;std::vectorr;while(it!=t.end()){r.push_back(boost::fusion::as_nview(*it));it++;}//returnr;}预期的是T是前向序列

c++ - 多读/单写类的线程安全

我正在研究一个经常阅读但很少写的集合。classA{boost::shared_ptr>_mySet;public:voidadd(intv){boost::shared_ptr>tmpSet(newstd::set(*_mySet));tmpSet->insert(v);//inserttotmpSet_mySet=tmpSet;//swap_mySet}voidcheck(intv){boost::shared_ptr>theSet=_mySet;if(theSet->find(v)!=theSet->end()){//dosomethingirrelevant}}};在类中,ad

c++ - 如何制作适用于 gcc 4.6 的递归 boost::variant?

我正在解码bencode,并且有一些代码适用于gcc4.4。但是最近升级到gcc4.6后,此代码不再生成:#ifndefBENCODE_VALUETYPES_H#defineBENCODE_VALUETYPES_H#include#include#include#includenamespacebencode{typedefboost::make_recursive_variant,std::map>::typeValue;typedefstd::mapValueDictionary;typedefstd::vectorValueVector;};#endifg++给出了这个错误信息:

c++ - 使用带有绑定(bind)的 boost 字符串算法谓词

编译这个例子#include#include#include#include#includeusingnamespacestd;intmain(int,char**){vectortest;test.push_back("xtest2");test.push_back("test3");ostream_iteratorout_it(cout,"\n");remove_copy_if(test.begin(),test.end(),out_it,boost::bind(boost::algorithm::starts_with,_1,"x"));}因错误而失败nomatchingfunc

c++ - 使用挂起的 read_async_some 关闭 boost::asio::serial_port

我正在链接read_async_some()调用以从串行端口异步读取。在某些时候,我需要取消异步读取并在关联的处理程序中检测到这一事实。来自thedocumentationforcancel(),我希望通过检查传递给我的处理程序的error_code来做到这一点:Thisfunctioncausesalloutstandingasynchronousreadorwriteoperationstofinishimmediately,andthehandlersforcancelledoperationswillbepassedtheboost::asio::error::operatio

c++ - 如何仅使用 boost/standard 库在 C++ 中读/写图像?

这可能吗?图像的格式无关紧要,但我必须能够打开它,将像素数据读入某种数组,使用修改后的像素数据集创建新图像。谢谢! 最佳答案 Boost.GIL有好的videotutorial它向您展示了如何以非常通用但高效的方式读取/写入和处理原始图像数据。 关于c++-如何仅使用boost/standard库在C++中读/写图像?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/9761910