草庐IT

boost-move

全部标签

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++ - move 是 c++ 中的关键字吗?

我正在编写一个程序并有一个名为“移动”的函数。但它在我的代码块中突出显示?move是c++中的保留字吗?如果是,它有什么作用?Ihaveitasvoidmove(doublet,doubleu) 最佳答案 不是关键字,而是有一个常用的标准库函数,叫做std::move;设置IDE语法突出显示的人决定突出显示它。为避免与阅读您的代码的人混淆,将您的函数称为其他名称是个好主意。 关于c++-move是c++中的关键字吗?,我们在StackOverflow上找到一个类似的问题:

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++ - "move semantics"和 "rvalue reference"的 Visual Studio 实现

我看到了一个关于c++11并发性的Youtube视频(第3部分)和以下代码,它在视频中编译并生成了正确的结果。但是,我在使用VisualStudio2012时遇到此代码的编译错误。编译器提示toSin(list&&)的参数类型.如果我将参数类型更改为list&,编译的代码。我的问题是move(list)返回了什么在_tmain(),它是右值引用还是只是一个引用?#include"stdafx.h"#include#include#include#include#includeusingnamespacestd;voidtoSin(list&&list){//this_thread::s

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

c++ - 如何在不使用 C++0x 的情况下创建 lambda 函数来匹配 boost::function 参数?

如何使用boost或STL创建lambda函数以匹配中第三段代码中F期望的boost::function参数主?#include#includevoidF(inta,boost::functionf){std::cout我不能使用C++0x并且想避免创建几个单独的函数。如果有帮助,我可以使用boost::function以外的东西,我的首要任务是简洁地创建lambda。 最佳答案 #include//STL#include//Boost.Lambda#include//Boost.Pheonix#include//Boost.Phe