草庐IT

exception-derived

全部标签

php - 未捕获的 MongoDB\Driver\Exception\ConnectionException : $or must be an array - PHP

我正在尝试使用MongoDB'sPHPdriver的$or运算符进行查询,但我收到以下错误:Fatalerror:UncaughtMongoDB\Driver\Exception\ConnectionException:$ormustbeanarrayin/path/to/file.php:83Stacktrace:#0/path/to/file.php(83):MongoDB\Driver\Manager->executeQuery('userAccou...',Object(MongoDB\Driver\Query))#1{main}thrownin/path/to/file.ph

php - 未捕获的 MongoDB\Driver\Exception\ConnectionException : $or must be an array - PHP

我正在尝试使用MongoDB'sPHPdriver的$or运算符进行查询,但我收到以下错误:Fatalerror:UncaughtMongoDB\Driver\Exception\ConnectionException:$ormustbeanarrayin/path/to/file.php:83Stacktrace:#0/path/to/file.php(83):MongoDB\Driver\Manager->executeQuery('userAccou...',Object(MongoDB\Driver\Query))#1{main}thrownin/path/to/file.ph

c++ - 我可以复制构造带有错误信息的 boost::exception 吗?

考虑以下使用boost异常类的代码:classexception:virtualpublicboost::exception{//...};templateclassexception_impl:virtualpublicstd::exception,publicExc{public:exception_impl(constExc&exc):Exc(exc){}virtualconstchar*what()constthrow(){return"blah";}};(实际上这段代码更复杂。例如,exception_impl仅从std::exception派生,如果后者还不是直接或间接基类

c++ - 在基本 ctor-initialiser 中将其强制转换为 `Derived*` 是否合法?

给出以下CRTP示例:templateintfoo(T*const){return0;}templatestructBase{Base():bar(foo(static_cast(this)){};intbar;};structDerived1:Base{};是this的转换至Derived*这里有效吗?我似乎记得可能不是,但现在找不到具体的证据。this的“自然”类型在这个阶段是Base*const,并且在某些情况下,甚至可以静态转换this初始化期间的指针不正常,例如在基础构造完成之前向上转换(12.7/3)。@DeadMG说:there'sanexplicitexceptioni

c++ - 当抛出异常的代码链接到使用 -fno-exceptions 编译的库时会发生什么?

具体来说,我想知道GCC对抛出异常的代码在链接到使用-fno-exceptions编译的代码时的行为做出了哪些保证(如果有的话)。GNUlibstdc++手册说以下here。Beforedetailingthelibrarysupportfor-fno-exceptions,firstapassingnoteonthethingslostwhenthisflagisused:itwillbreakexceptionstryingtopassthroughcodecompiledwith-fno-exceptionswhetherornotthatcodehasanytryorcatch

c++ - SWIG 包装库中 __cxa_allocate_exception 期间的段错误

在为Ruby开发一个SWIG封装的C++库时,我们在C++代码内的异常处理过程中遇到了无法解释的崩溃。我不确定重新创建问题的具体情况,但它首先发生在调用std::uncaught_exception期间,然后在一些代码更改后,移至__cxa_allocate_exception在异常构造期间。GDB和valgrind都没有提供任何有关崩溃原因的见解。我找到了几个类似问题的引用资料,包括:http://wiki.fifengine.de/Segfault_in_cxa_allocate_exceptionhttp://forums.fifengine.de/index.php?topic

c++ - 在标准中,什么是 "derived-declarator-type"?

在C++(C++11)标准的不同地方,声明是根据derived-declarator-type-list来描述的。我正在研究右值引用,在这种情况下使用这个术语是至关重要的(第8.3.2节):InadeclarationTDwhereDhaseitheroftheforms    &attribute-specifier-seqoptD1    &&attribute-specifier-seqoptD1andthetypeoftheidentifierinthedeclarationTD1is“derived-declarator-type-listT,”thenthetypeofth

c++ - static_cast<Derived *>(Base pointer) 是否应该给出编译时错误?

static_cast(Basepointer)是否应该给出编译时错误?classA{public:A(){}};classB:publicA{public:B(){}};intmain(){A*a=newA();B*b=static_cast(a);//CompileError?} 最佳答案 它不会给出编译时错误,因为Base-Derived关系可以在运行时存在,具体取决于被强制转换的指针的地址。static_cast总是成功,但如果你不转换为正确的类型,则会引发undefined-behavior。dynamic_cast可能会

c++ - 为什么 C++ 不使用 std::nested_exception 来允许从析构函数中抛出?

从析构函数抛出异常的主要问题是,在调用析构函数的那一刻,另一个异常可能“正在运行”(std::uncaught_exception()==true),所以它是在这种情况下该怎么做并不明显。用新异常“覆盖”旧异常将是处理这种情况的可能方法之一。但决定在这种情况下必须调用std::terminate(或另一个std::terminate_handler)。C++11通过std::nested_exception类引入了嵌套异常功能。此功能可用于解决上述问题。旧的(未捕获的)异常可以嵌套到新的异常中(反之亦然?),然后可以抛出嵌套的异常。但是这个想法没有被使用。std::terminate在

具有未定义行为的 C++ 代码,编译器生成 std​​::exception

我在C++中遇到了一个有趣的安全编码规则,它指出:Donotreenterafunctionduringtheinitializationofastaticvariabledeclaration.Ifafunctionisreenteredduringtheconstantinitializationofastaticobjectinsidethatfunction,thebehavioroftheprogramisundefined.Infiniterecursionisnotrequiredtotriggerundefinedbehavior,thefunctionneedonly