草庐IT

auto_start

全部标签

c++ - 使用 '&'进行迭代时 'auto'符号有什么作用

最近我在C++中使用auto时遇到了非常非常奇怪的问题,只是......看看下面的代码片段:我的主要功能:#include#include#includeintmain(){inta=10,b=20,c=30;listwhat;what.push_back(a);what.push_back(b);what.push_back(c);read(what);return0;}这里的函数是:voidread(constlist&con){for(autoit:con){printf("%p\n",&it);cout这是输出:0x7fffefff66a4100x7fffefff66a4200

c++ - 无法在 VS 14 CTP : conditional expression of type 'void' is illegal 中使用 auto 声明 lambda

使用VisualStudio2014CTP、C++(v140)编译器:autogp=[&](BYTE*buff){autogp1=[](char*bff,char**p1){*p1=strstr((char*)bff,"(");return(*p1);};};错误:conditionalexpressionoftype'void'isillegal(也许auto真的输入错误?)如果我将内部lambda声明为std::functiongp1然后就可以了是我做错了什么还是编译器错误? 最佳答案 我没有运行2014,但您可能需要指定内部l

c++ - 函数返回 auto 自动参数 munmap_chunk() : invalid pointer

我正在测试newfeature对于GCC4.9(自动输入参数)并出现一些奇怪的错误。#include#includeautofoo(autov){for(auto&&i:v)std::cout{1,2,3});}这给我以下错误:***glibcdetected***./a.out:munmap_chunk():invalidpointer:0x00007f87f58c6dc0***=======Backtrace:=========/lib/x86_64-linux-gnu/libc.so.6(+0x7e846)[0x7f87f4e4c846]./a.out[0x400803]/lib

c++ - 黑莓模拟器 : ViewFinder starting failed 级联相机错误

我正在尝试在BlackberryCascades10.2中打开相机importbb.cascades.multimedia1.0importbb.multimedia1.0importbb.cascades1.2importbb.system1.2Page{titleBar:TitleBar{title:"QMLCameraSampleApp"}content:Camera{id:qmlCameraObjpropertyboolphotoBeingTakenonTouch:{if(photoBeingTaken==false){photoBeingTaken=true;qmlCamer

c++ - std::max 与 lambda 和 auto

C++11难道不能做到这一点吗?使用当前的clang编译器(OSX10.8上的Xcode5)无法编译:std::max_element(group->GetComponents().begin(),group->GetComponents().end(),[](autoa,autob){returna.length>b.length;});错误信息是:Stuff.cp:68:40:函数原型(prototype)中不允许使用“auto” 最佳答案 在C++1y中你有通用的lambda,所以语法将在clang3.5中编译。.lambda

c++ - 以下哪一项是 "auto"推导指针类型的更正确方法?

关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭8年前。Improvethisquestion(非常基本的问题:)我发现以下两种方式都生成int*类型。我可以知道哪个更合适吗?inti=42;autoa=&i;auto*b=&i;(我试图将指针示例与引用示例相关联:autoc=i;和auto&d=i;。但似乎类比在这里不起作用.)编辑:我还发现另一个(密切相关的)例子很奇怪:autoi=42,p=&i;//failsatcompilationautoi=42,*p=&i;//pas

c++14 static constexpr auto 与 odr 用法

我有以下C++14代码:templatestructTest{staticconstexprautosomething{T::foo()};};这很好,只要T::foo()也是一个constexpr。现在我知道something是ODR使用的,所以我需要提供命名空间声明。我应该使用什么语法?templateconstexprautoTest::something;不起作用。谢谢! 最佳答案 通过using定义的类型名怎么样?templatestructTest{usingsomeType=decltype(T::foo());sta

c++ - 警告 : auto-importing has been activated without --enable-auto-import specified on the command line

我的环境:QtCreator2.3.1Qt4.7.4(32位)Windows7旗舰版(64位)尝试在QtforWindows中重建项目时,我遇到以下编译器警告:warning:auto-importinghasbeenactivatedwithout--enable-auto-importspecifiedonthecommandline.Thisshouldworkunlessitinvolvesconstantdatastructuresreferencingsymbolsfromauto-importedDLLs.发出此警告的项目包含一个DLL文件。尽管有警告,DLL中的类和函数

Spring Boot 报错:Web server failed to start. Port 8080 was already in use.

报错信息:Webserverfailedtostart.Port8080wasalreadyinuse报错原因:端口被占用。解决方法:解决方法一:修改端口;         修改配置文件,加上参数:server.port=8014解决方法二:关闭占用端口的进程。    1.使用cmd命令查看端口号占用情况,例如查看端口8014,可以看出进程号为10728;        netstat-ano|findstr端口号        2.关闭该进程        方法一:使用任务管理器关闭:        菜单栏->右键->任务管理器->详细信息,根据PID排序找到PID为10728的进程,选择后

c++ - 试图理解 auto_ptr

我试图了解有关auto_ptr类如何工作的某些细节。假设您有以下类(class)(我是在一个网站上找到的,该网站上有人解释了赋值运算符的要点)。classTFoo:publicTSuperFoo{auto_ptrfBar1;auto_ptrfBar2;public:TFoo&TFoo::operator=(constTFoo&that);//variousothermethoddefinitionsgohere...}现在是赋值运算符的实现。TFoo&TFoo::operator=(constTFoo&that){if(this!=&that){auto_ptrbar1=newTBar