草庐IT

unique_no

全部标签

C++ Windows 命令提示符 C1083 "Cannot open include file: ' Magick++.h' No such file or directory"

自从我取得任何进展、搜索文档和链接以来已经过去了4个多小时,坦率地说,我没有想法。就这样吧。背景我正在命令提示符下编译C++程序我是命令提示符的新手,也是c++的新手我正在用Notepad++(不是VS)编写这个程序,但安装了VS,所以我可以编译我正在尝试通过Magick++使用ImageMagick,Magick++是它的C++API包装器。主程序目录C:/ProgramFiles(x86)/CameraSoftware/myCameraProgram.cppMagick++目录C:/ProgramFiles(x86)/ImageSoftware/Magick++/lib/Magic

c++ - 前向声明、unique_ptr 和类内初始化器

我已阅读Isstd::unique_ptrrequiredtoknowthefulldefinitionofT?和Forwarddeclarationwithunique_ptr?,但我的问题更具体。以下编译://Compilewith$g++-std=c++11-c#includeclassA;//fwddeclarationclassAUser{AUser();//definedelsewhere~AUser();//definedelsewherestd::unique_ptrm_a;};以下不是://Compilewith$g++-std=c++11-c#includeclas

c++ - 为什么不允许使用 `make_unique<T[N]>`?

假设命名空间std贯穿始终。C++14委员会草案N3690定义了std::make_unique因此:[n3690:20.9.1.4]:unique_ptrcreation   [unique.ptr.create]templateunique_ptrmake_unique(Args&&...args);1Remarks:ThisfunctionshallnotparticipateinoverloadresolutionunlessTisnotanarray.2Returns:unique_ptr(newT(std::forward(args)...)).templateunique

c++ - 使用 unique_ptr 作为方法参数 - 优点和缺点

我注意到如果我有以下内容:#includeusingnamespacestd;classFoo{public:Foo();};classWobble{public:voidSetWibble(unique_ptrfoo){this->wibble=move(foo);}//Ilikereturningarefasitgivescontrolto//theuserofmyframeworkoverrecievinga&oracopyFoo&GetWibble(){return*wibble;}unique_ptrwibble;};int_tmain(intargc,_TCHAR*argv

c++ - unique_ptr、nullptr 并支持 gcc 4.5.x 和 4.6.x

我正在开发一个有两个不同最终用户的库,其中一个使用gcc4.5.3,另一个刚刚迁移到gcc4.6.3。该库使用新的C++11智能指针(特别是unique_ptr)并在gcc4.5.3上编译良好。然而,在这两个版本之间,gcc开始支持nullptr,因此unique_ptr的API发生了变化,以更接近标准。现在这样做,下面的代码从好到模棱两可unique_ptrup(newint(30));...if(up==0)//ambiguouscallnowtounique_ptr(int)for0是否有一种干净的(即,下一句)方法来更改上面的if语句,以便它在有和没有nullptr的情况下都有

C++11 : unique_ptr complains about incomplete type, 但是当我包装它时不是

SO上已经有很多关于unique_ptr和不完整类型的问题,但没有一个能给我一个概念来理解为什么以下内容不起作用://error:...std::pair::secondhasincompletetypetemplatestructImpl{typedeftypenamestd::unordered_map>::iteratoriter_type;std::unique_ptrptr;Impl():ptr(newiter_type()){}};intmain(){Impl();return0;}而以下是:templatestructImpl{structWrapper{typedeft

c++ - 为什么 "cc1plus: warning: unrecognized command line option"选项的 "no-"仅在出现另一个警告时由 g++ 标记?

>catwarning.cpp#pragmafoobar>catno_warning.cpp#pragmamessage"foobar">g++-Wall-Wno-foobar-cwarning.cppwarning.cpp:1:0:warning:ignoring#pragmafoobar[-Wunknown-pragmas]cc1plus:warning:unrecognizedcommandlineoption"-Wno-foobar"[enabledbydefault]>g++-Wall-Wno-foobar-cno_warning.cppno_warning.cpp:1:17

c++ - 如何将 std::unique_ptr<T> 与返回 int 的接口(interface)一起使用?

我想将open/closePOSIXAPI包装到一个RAII兼容对象中,例如std::unique_ptr。但是open函数返回一个int(即不是HANDLE,它是指向void的指针),并且我不确定如何将std::unique_ptr模板类与int一起使用。有人可以帮帮我吗? 最佳答案 真的,您想要的只是让close(intfileHandle)为您管理,对吗?为什么不创建一个带有为您调用close()的析构函数的简单C++类?我认为这就是您要寻找的行为。std::shared_ptr,friend只处理用new创建的堆指针,会调用

c++ - 是否所有官方 Qt 二进制文件都使用 -no-exceptions 构建?

如果我写try{throwstd::exception("Exception");}catch(std::exception&ex){qDebug("GameOver");}在我的主函数(或其他任何地方)中,我的Qt应用程序崩溃了。Exceptionhandlingdoesn'tworkwithQtonWindows中描述了这种效果(5年前).原来的发布者显然通过自己重新配置和重建QtSDK(显式启用-exceptions)解决了这个问题,但我很难相信所有Qt二进制文件都关闭了异常并且每个使用异常的人都必须这样做。谁能告诉我这是记录在案的地方,告诉我这是真的还是我在这里做错了什么?我现

c++ - 防止对 std::unique_ptr 的不安全取消引用

摘自cppcon2015的幻灯片:unique_ptrf(){autoa=make_unique();returna;}//Whydoesthisevencompile?constA&dangling=*f();//BOOM!!!use(dangling);我的问题是:对于*this的右值引用,这可以解决吗?我在cppreference的规范中看到:typenamestd::add_lvalue_reference::typeoperator*()const;问题:不允许operator*用于右值unique_ptr并且只对左值unique_ptr取消引用有效吗?仍然有有效的用例来保持