草庐IT

Application_End

全部标签

c++ - QDebug类结构: determine end of input via `operator<<`

Qt有一个很好的调试功能,就是这样叫的qDebug()它生成一行包含一些对象的“标准字符串”,并且——这是重要的部分——打印\n并在second_object之后冲洗Steam.我想通过我的所有类都有一个std::stringto_string()的约定来重现该行为我调用的方法:structmyDebug{templatemyDebug&operator我现在的问题是:在返回*this之后有没有办法找出它?第二次不再调用返回的对象?这样我就可以打印std::endl?qDebug()似乎可以做到这一点。 最佳答案 找到解决方案,发现

c++ - 错误 : control Reaches end of non void function

我正在学习C++,我从教科书上抄了这段代码,在编译代码时,最后出现错误。错误说:ControlReachesendofnon-voidfunction它位于代码的末尾:#include"ComplexNumber.hpp"#includeComplexNumber::ComplexNumber(){mRealPart=0.0;mImaginaryPart=0.0;}ComplexNumber::ComplexNumber(doublex,doubley){mRealPart=x;mImaginaryPart=y;}doubleComplexNumber::CalculateModulu

c++ - 当我什至无法进入代码时如何调试 "This application has requested the Runtime to terminate it in an unusual way."?

我有一个C++程序,它在进程启动后立即给出此错误-显然是在任何用户代码执行之前。它仅在启用内联时发生。即使内置了调试符号,我也无法进入代码。当我在VisualStudio中按下F10时,我收到了错误并且程序停止了。我在“调试/异常”中检查了所有异常/检查,但仍然没有休息。通常我会认为这样的事情是由于缺少运行时依赖项造成的,但我很肯定这不是这里的情况(已通过DependencyWalker验证)。编辑:我使用了SteveTownsend对CDB的推荐,现在我能够单步执行程序的预用户代码部分。最终的堆栈跟踪是:Child-SPRetAddrCallSite00000000`0008e308

c++ - g++ : Using singleton in an embedded application

我正在使用C++中的GNUARM工具链使用GCC4.8为CortexM3开发嵌入式应用程序。该应用程序使用了一些通过函数局部静态变量实例化的单例,就像这样(真实代码):GlobalDataTypeRegistry&GlobalDataTypeRegistry::instance(){staticGlobalDataTypeRegistryinst;returninst;}这是在C++中实现单例的经典方法。问题是一旦我使用这种实例化,输出代码大小就会激增,这显然意味着编译器/链接器添加了一些服务代码以正确初始化/销毁单例对象。这是允许重现问题的最小示例:这将编译成66k代码(-Os):s

c++ - {} 是传递给需要迭代器(代表某个容器的 std::end() )的函数的有效参数吗?

在boostdirectory_iteratorexample-howtolistdirectoryfilesnotrecursive(参见thisanswer)中是示例代码#include#include#include...usingnamespaceboost::filesystem;for(auto&entry:boost::make_iterator_range(directory_iterator(p),{})){std::cout(p是boost::filesystem::path类型。)在查看documentationformake_iterator_range时,我认

c++ - "Control reaches end on non-void function"with do { 返回结果; } 而(条件);

我有以下功能(简化示例):QByteArrayDecompressBytes(constQByteArray&content){/*functionbody(withotherreturnexpressions)*/do{returncontent;}while(content.size()!=0);}添加最后一行用于测试,替换使用的宏。VisualStudio没有发现此代码有问题,但g++生成了warning:controlreachesendofnon-voidfunction[-Wreturn-type]将最后一行更改为returncontent;删除警告。我的问题:为什么编译器

c++ - 为非数组重载 std::begin() 和 std::end()

假设我有以下Data类:structData{charfoo[8];charbar;};和以下函数,my_algorithm,它采用一对char*(类似于STL算法):voidmy_algorithm(char*first,char*last);对于Data的foo数据成员,而不是像这样调用my_algorithm():Datadata;my_algorithm(data.foo,data.foo+8);我可以使用std::begin()和std::end()便捷功能模板:my_algorithm(std::begin(data.foo),std::end(data.foo));我想实

c++ - 删除时 std::list end() 迭代器位置是否改变?

在下面的循环中,我使用了一个预先计算好的结束迭代器:std::list::iteratorend=MyList.end();for(std::list::iteratorit=MyList.begin();it!=end;)it=MyList.erase(it);当删除std::list中的元素时,MyList.end()是否可以更改其值以便end!=MyList.end()不再存在? 最佳答案 没有。n337623.3.5.4iteratorerase(const_iteratorposition);iteratorerase(c

c++ - 定义为 "_end[LEN]"的数组在 C/C++ 中导致段错误

这个问题在这里已经有了答案:WhataretherulesaboutusinganunderscoreinaC++identifier?(5个答案)关闭7年前。我试图在C/C++中定义一个名为_end的全局数组,大小约为1000,但即使我只是简单地迭代它,我也会遇到段错误。名称“_end”在导致此类问题的C/C++中是否非常特殊?或者这可能是一个非常严重的错误......(代码附在下面,它在g++4.3.2、4.5.2、4.9.2等中中断)#includeusingnamespacestd;int_end[1111];intmain(){for(inti=0;i您可以在https://

c++ - C++ 代码 `x.erase(std::remove(x.begin(), x.end(), ' '), x.end())` 是如何工作的?

问题是我通常会使用for循环来处理这种事情,但这种方法似乎更有效率。cplusplus的文档对我来说有点难以理解。std::stringno_space(std::stringx){x.erase(std::remove(x.begin(),x.end(),''),x.end());returnx;} 最佳答案 函数std::remove(x.begin,x.end),'')将元素移动到字符串的末尾,函数std::erase实际上删除了被移动到字符串末尾的元素。您还可以在文档中阅读更多相关信息enterlinkdescription