草庐IT

unique_image

全部标签

c++ - std::bind 通常与仅移动类型一起使用,特别是 std::unique_ptr 吗?

我正在尝试使用boost::asio并遇到了一些问题。我正在尝试编译以下代码:std::unique_ptrbuffer=buffers.pop();std::functiont=std::bind(&tcp_client::handle_read_done,this,std::placeholders::_1,std::placeholders::_2,std::move(buffer));如果我排除std::move(buffer),一切正常,当然是从handle_read_done的签名和作为std::bind中传递的参数。当试图将它传递给boost::asio::async_r

c++ - 为什么不再允许从数组的 unique_ptr 创建 shared_ptr?

来自cppreference:InC++11andC++14itisvalidtoconstructastd::shared_ptrfromastd::unique_ptr:std::unique_ptrarr(newint[1]);std::shared_ptrptr(std::move(arr));Sincetheshared_ptrobtainsitsdeleter(astd::default_deleteobject)fromtheunique_ptr,thearraywillbecorrectlydeallocated.ThisisnolongerallowedinC++17

c++ - 在这种情况下我应该使用 unique_ptr 还是 shared_ptr?

在我的QT应用程序的主窗口中,我使用std::shared_ptr来保存指向我的网络服务实例的指针,该实例管理与多个客户端的所有连接。现在,我必须将这个指针传递给多个子窗口,以便它们可以与客户端通信。我最好在主窗口和子窗口中使用std::shared_ptr成员变量并在创建子窗口时传递复制它,还是使用std更好::unique_ptr并将原始指针传递给子窗口,因为主窗口无论如何都会比子窗口长寿?非常感谢! 最佳答案 主要的实际区别是当主窗口被销毁而子窗口仍然存在并正在使用网络服务时会发生什么:如果您使用unique_ptr并传递原始

c++ - 为什么 std::unique_ptr 重置与赋值不同?

我想知道为什么std::unique_ptrp=newMyClass;没有效果,但是std::unique_ptrp;p.reset(newMyClass);很好。我有点理解它们的不同之处,但我想知道为什么选择让它们不同。assignment和reset不一样有什么危险? 最佳答案 首先,std::unique_ptrp=newMyClass;不是赋值,是copyinitialization.它不起作用,因为constructorofstd::unique采用原始指针标记为explicit:explicitunique_ptr(po

windows - 在 Windows 中什么是 "runtime image"?

关闭。这个问题是off-topic.它目前不接受答案。想改进这个问题吗?Updatethequestion所以它是on-topic用于堆栈溢出。关闭9年前。Improvethisquestion正在看《MySQL5.0认证学习指南》这本书。第362页指出:•mysql-debug包含对调试的支持。通常,您不会选择此服务器用于生产,因为它具有更大的运行时图像并使用更多内存。什么是“图像”?我进行了广泛的搜索以试图找到答案。

windows - Windows 中的 ElasticSearch docker image vm max map count

我是Docker和Elasticsearch的新手。我正在使用Windows7机器。我正在使用docker-composeup来启动docker容器。我的yml文件有elasticsearch:image:elasticsearch:5.1.1environment:ES_JAVA_OPTS:"-Xms1g-Xmx1g"连同其他链接图像。我正在使用docker调出elasticsearch图像,当我这样做时出现以下错误[36melasticsearch_1|←[0mERROR:bootstrapchecksfailed[36melasticsearch_1|←[0mmaxvirtual

c++ - Gdiplus::Image::GetWidth() 和一堆其他 setter/getter 不应该是 "const"吗?

为什么它们不是常量?我认为这是有缺陷的API设计。还是我遗漏了什么?UINTGetWidth();UINTGetHeight();...对比UINTGetWidth()const;UINTGetHeight()const;... 最佳答案 有缺陷的API设计?C风格的C++头文件?来自带给我们的团队CString?不,不可能……说真的,不要指望GoTW任何Win32API中的-levelC++使用,或者不仅仅是围绕C样式句柄的基本包装器。HerbSutter一直忙于.NET:ingC++,而不是改进Microsoft库设计。WTL与

【C++】C++11——智能指针、内存泄漏、智能指针的使用和原理、RAII、auto_ptr、unique_ptr、shared_ptr、weak_ptr

文章目录C++117.智能指针7.1内存泄漏7.2智能指针的概念7.3智能指针的使用7.3.1auto_ptr7.3.2unique_ptr7.3.3shared_ptr7.3.4weak_ptrC++117.智能指针7.1内存泄漏  什么是内存泄漏:  内存泄漏指因为疏忽或错误造成程序未能释放已经不再使用的内存的情况。内存泄漏并不是指内存在物理上的消失,而是应用程序分配某段内存后,因为设计错误,失去了对该段内存的控制,因而造成了内存的浪费。  内存泄漏通常由于程序在设计上的缺陷或错误,例如动态分配内存后,未在合适的时间或无法正确释放该段内存,而导致的。内存泄漏通常需要程序员通过分析程序源代码

C#对图片Image转换为Bitmap并解析图片中的条码

首先,你需要安装ZXing.Net库。你可以通过NuGet包管理器来安装。usingZXing;usingZXing.Common;usingZXing.QrCode;publicclassTest{ publicstringDecodeBarcode(Bitmapbitmap) { varreader=newBarcodeReader(); varresult=reader.Decode(bitmap); returnresult?.Text; }publicvoidCode(){stringimagePath=@"C:\path\to\your\image.jpg";//替换为你的图片路径

c# - x :Bind image with null string

在XAML中,我有以下行:在View模型中:publicstringMainPic{get{if(Data==null)returndefault(string);elsereturnData.Photos.ElementAtOrDefault(0).url;}}应用程序编译正常,但在执行期间(因为数据在几秒后填充),应用程序崩溃并出现以下异常:System.ArgumentException:Theparameterisincorrect.调试器中断于:privatevoidUpdate_ViewModel_MainPic(global::System.Stringobj,intph