草庐IT

except_list

全部标签

c++ - 为什么嵌套的initializer_list会导致内存泄漏

最近我将我的项目升级到VisualStudio2013。因此现在可以使用initializer_list功能。我需要在我的单元测试中初始化测试数据。但是我在使用嵌套的initialize_lists时遇到了内存泄漏。#include#includestructTest_Fixture{Test_Fixture():test_data({std::make_shared>(std::vector{0,1}),std::make_shared>(std::vector{2,3,4})}){}std::vector>>test_data;};BOOST_FIXTURE_TEST_CASE(t

c++ - 空 initializer_list 上的赋值运算符

您能解释一下STL容器如何处理初始化列表为空的赋值运算符吗?当我做这样的事情时:vectorv;v={};调用的函数不是:vector&operator=(initializer_listil);但是:vector&operator=(vector&&x);另一方面,当我对自己的类(class)做类似的事情时:structA{A&operator=(constA&){return*this;}A&operator=(A&&){return*this;}A&operator=(initializer_list){return*this;}};/*...*/Aa;a={};代码无法在VS2

c++ - 为什么 regex_match 抛出 "complexity exception"?

我正在尝试测试(使用boost::regex)文件中的一行是否仅包含由空格分隔的数字条目。我遇到了一个我不明白的异常(见下文)。如果有人能解释为什么抛出它,那就太好了。也许我在这里以定义模式的方式做了一些愚蠢的事情?这是代码://regex_test.cpp#include#include#includeusingnamespacestd;usingnamespaceboost;intmain(){//Mybasicpatterntotestforasinglenumericexpressionconststringnumeric_value_pattern="(?:-|\\+)?[[

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

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

c++ - 如何使用存储在 c++ 中的 std vector 中的 std::list 迭代器制作复制安全容器?

对于我的GUI,我需要一个具有以下用途的类来管理控件(窗口、按钮等)通过[index]随机访问元素通过["key"]随机访问元素指针稳定性,因此ptr=&container[index]不会因添加或删除元素而改变复制安全。如果像container2=conatiner1(深层复制)那样使用“=”,则所有元素都必须存储在容器中并进行复制列表中元素的顺序必须可变,但指向元素的指针必须保持有效。如果ptr1=container[1]和ptr2=container[2],那么交换1和2的顺序后,ptr1==container[2]和ptr2==container[1]我得出的结论是std::l

【错误解决】requests.exceptions.SSLError:wrong version number (_ssl.c:1131)

错误解决:requests.exceptions.SSLError:wrongversionnumber(_ssl.c:1131)requests.exceptions.SSLError:HTTPSConnectionPool(host=‘192.168.79.128’,port=8080):Maxretriesexceededwithurl:/admin/login(CausedbySSLError(SSLError(1,‘[SSL:WRONG_VERSION_NUMBER]wrongversionnumber(_ssl.c:1131)’)))尝试1:进入电脑的“网络和Internet“设置

c++ - 让 Visual Studio 中断用户(std::exception)异常?

我的代码抛出未处理的异常,但VisualStudio中的调试器只中断系统抛出的异常。例如,getaddrinfo的返回值不为零,我的异常应该首先抛出-事实上,如果我在第171行放置一个断点,它会被命中-但调试器只在调用socket时中断。我知道Ihavetoaddmyowntypesexplicitly,orelsecheckAllC++Exceptionsnotinthislist,在ExceptionSettings中,但这是我抛出的std::exception,而std::exception是检查过。如何让VisualStudio调试器在出现异常时自动中断?

c++ - 为什么这段代码会出现 "exception spec is more lax than base"错误?

尝试使用Xcode6.1中的clang版本(基于LLVM3.5svn的clang-600.0.54)编译以下代码,使用-std=c++11和-stdlib=libc++给我一些我不太明白的错误。#includestructImpl{typedefstd::functionL;Ll;inti;};structHndl{Impl*impl;Hndl(Impl*i):impl(i){}~Hndl()noexcept(false){}};intmain(intargc,char*argv[]){Hndlh(newImpl());h.impl->l=[=]{h.impl->i=42;};retu

c++ - 将图 (adjacency_list) 复制到另一个图

如何将adjacency_list类型的图复制到另一个adjacency_list类型的图?typedefadjacency_listMyGraph;MyGraphg1,g2;//processingg1:addingverticesandedges...//processingg2:addingsomeverticesandedges...g1.clear();g1=g2//thisgivesanexecutionerror(exception)g1=MyGraph(g2);//thisalsogivesanexecutionerrorg2.clear();

c++ - 模板特化站点报告 "too few template-parameter-lists"错误

代码某处有错误,但我不知道如何解决。它说“模板参数列表太少”。我不明白哪个是错误的。代码如下:#if!defined(VECTOR_H_INCLUDED)#defineVECTOR_H_INCLUDED#include//forsize_tnamespaceVec{classVector_base{public:explicitVector_base(){}};templateclassVector:publicVector_base{typedefVectorME;explicitVector(T,T,T);doubledot(constME&v)const;T&operator[]