草庐IT

has_typedef_X

全部标签

C++ 使用别名访问嵌套类型(使用 vs typedef)

今天我们发现了一个令人困惑的C++11别名声明行为。这是示例:templatestructQ{typedefTt;};templatevoidfoo(Qq){usingq_t=Q;//typedefQq_t;//ifweuncommentthisandcomment'using'theexamplecompilestypenameq_t::tqwe;//’}intmain(intargc,char*argv[]){Qq;foo(q);return0;}ISO14882(C++11)规定这两个声明必须具有相同的语义(第145页)。但是,如果我们用“using”声明了q_t,则该示例不会使

c++ - 使用 -g 选项编译但 "Single stepping until exit from function main, which has no line number information"

我在使用gdb时遇到了一些问题。这是我在一个名为main.cpp的文件中的代码#includevoidmyfunc();intmain(){charmsg[]="HelloWorld!";myfunc();std::cout我使用这个命令来编译这段代码:g++-g-Wallmain.cpp-ofoo接下来,我使用了gdb:$gdbfoo(gdb)startTemporarybreakpoint1at0x80487c3Startingprogram:/home/laptop/workspace/fooTemporarybreakpoint1,0x080487c3inmain()(gdb)

c++ - 错误 : Element <EnableEnhancedInstructionSet> has an invalid value of "NoExtensions"

我想在虚拟机WindowsXP下VS2010下打开别人的C++项目。问题是,我认为该项目似乎是在Windows7下的VS2012下开发的。我已经成功转换了它的相关配置,感谢互联网。但是现在,当我尝试构建这个项目时,出现了以下错误:C:\ProgramFiles\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(147,5):error:Elementhasaninvalidvalueof"NoExtensions".似乎配置更改导致了这个问题。我所做的是将Project->Properties-

NVIDIA-SMI has failed because it couldn‘t communicate with the NVIDIA driver解决办法

NVIDIA-SMIhasfailedbecauseitcouldn‘tcommunicatewiththeNVIDIAdriver解决办法参考链接1参考链接2参考链接32023.3.17更新今天突然又出现这个问题,一开始我就以为内核自动更新,便想去降低内核版本,一看旧版本的内核,发现都被自动删除了,然后我之前也将内核自动更新取消了啊,输入命令dpkg--get-selections|greplinux-image打印内核版本显示也是hold,按道理内核并没有更新。一开始没发现问题,便一直尝试下载旧版本内核来解决,一直没成功。最后无意间在ubuntu的应用中点开nvidiaxserverset

c++ - 带有类模板 typedef 参数的函数模板

以下代码是我在大型项目中尝试做的事情的示例:#include#include//standardtemplatetypedefworkaroundtemplatestructmyvar{typedefstd::vectorType;};templateTmax(typenamemyvar::Type&x)//Tmax(std::vector&x){Ty;y=*x.begin();for(typenamemyvar::Type::iteratorit=x.begin();it!=x.end();++it)if(*it>y)y=*it;returny;}intmain(intargc,ch

c++ - typedef 到模板类型

下面的问题是什么?typedefboost::shared_ptrSharedPtr;GCC给出以下错误:ISOC++forbidsdeclarationof‘shared_ptr’withnotype 最佳答案 C++(还)没有“模板类型定义”,您可以在其中“重命名”这样的模板。这是C++0x中添加的一个特性,其中这样的“typedef”被称为“别名模板”。目前最简单的解决方法是使用带有嵌套typedef的类模板:templatestructSharedPtr{typedefstd::shared_ptrType;};//usag

c++ - typedef-name 作为基类 : illegal but widely tolerated

[class.derived]的第一段说的是基类说明符,Ifthenamefoundisnotaclass-name,theprogramisill-formed.但是,一个simple测试表明Comeau和g++-ansi-pedantic都接受typedef-name作为基础。Boostheader上的简单grep-r'[^:]:mpl'表明流行的库通常依赖于这种行为。是否有任何编译器实际上拒绝了基说明符中类的typedef?GCC甚至检查基类类型是否不是const,这改进了非标准功能。有解决办法吗?我唯一能想到的就是用C++11别名模板替换typedef。一个模板化的别名声明声明

c++ - 返回 T<A> 的函数在某些 typedef 情况下无法编译

我不明白为什么func3()无法编译,当func2()和func4()做。g++4.1.2:error:'B::my_t'hasincompletetypeVS2008:errorC2079:'B::my_t'usesundefinedclass'A'templatestructC{Tmt_t;};templatestructB{typedefCC_type;Tmy_t;};structOther{};structA{Bfunc2();B::C_typefunc3();//error:'B::my_t'hasincompletetypeB::C_typefunc4();};intmai

c++ - 在函数上使用 typedef

在下文中,我如何使用typedef语法定义我的函数?typedefvoidF();//declaremyfunctionFf;//errorFf{} 最佳答案 函数的定义将遵循通常的语法://declaremyfunctionFf;//itisexactlyequivalentto:voidf();//definitionvoidf(){cout要测试该定义确实是之前声明的函数的定义,只需调用函数f()>after声明和before定义(阅读main()中的注释)://declarationFf;intmain(){f();//at

c++ - free.c 抛出异常 "this program has stopped working"

当我使用VisualC++2010Express的调试器运行程序(server.exe)时,它运行完美,但是当我将它作为exe运行时它却没有;它崩溃并显示“Server.exe已停止工作”对话框。接下来我将exe重命名为“ServerInstaller.exe”并且它工作了,所以我认为这是一个权限错误,但它不适用于管理员模式下的“Server.exe”。然后我将VC++中的调试器附加到“Server.exe”程序,它在“free.c”中出现异常。这个文件中的代码是void__cdecl_free_base(void*pBlock){intretval=0;if(pBlock==NULL