草庐IT

has-scope

全部标签

Ms Visual Studio : "Windows has triggered a breakpoint in javaw.exe" 上的 C++ 错误

我一直致力于我的软件C++和Java(使用MicrosoftVisualStudio2008和Eclipse构建),并且我一直在尝试将它从32位系统转移到64位系统。编译阶段没问题,但在执行时出现错误:"Windowshastriggeredabreakpointinjavaw.exe.Thismaybeduetocorruptionoftheheap,whichindicatesabuginjavaw.exeoranyoftheDLLsithasloaded-.ThismayalsobeduetouserpressingF12whilejavaw.exehasfocus.Theout

C++:为什么这个简单的 Scope Guard 有效?

到目前为止,每个看过的作用域守卫都有一个守卫bool变量。例如,请参阅此讨论:Thesimplestandneatestc++11ScopeGuard但是一个简单的守卫可以工作(gcc4.9,clang3.6.0):templatestructfinally_t:publicC{finally_t(C&&c):C(c){}~finally_t(){(*this)();}};templatestaticfinally_tfinally_create(C&&c){returnstd::forward(c);}#defineFINCAT_(a,b)a##b#defineFINCAT(a,b)

c++ - C++ 11 中 boost::scoped_ptr 的替代方案

我们刚刚将编译器升级到支持C++11的VC++2013。之前我们一直在使用来自Boost的shared_ptr和scoped_ptr类,但由于这是我们一直在使用的Boost类,我们正在寻找删除该依赖项。据我所知,std::shared_ptrs是boost::shared_ptrs的直接替代品,所以这(希望)很容易。但是,Boostscoped_ptrs的最佳替代品是什么(如果有的话)?会是unique_ptr吗?(老实说,虽然我写了代码,但那是大约10年前的事了,我已经忘记了使用scoped_ptrs的目的是什么......也许我只是在“玩”Boost,但到目前为止正如我所看到的,在

c++ - scoped_ptr 所有权

这个问题在这里已经有了答案:关闭9年前。PossibleDuplicate:WhatisasmartpointerandwhenshouldIuseone?我正在阅读anarticle我找到了一个小例子来演示boost::scoped_ptr的使用:#include#include#include#includestaticintcount=0;classprinter{intm_id;public:printer(void):m_id(count++){}~printer(void){std::coutp1(newprinter);boost::scoped_ptrp2(newpri

c++ - 使用 mingw-w64 工具链时,以 Release模式链接的 Regex Boost 库会发出 "duplicate section has different size"警告

在Release模式下链接我的项目时,我收到以下警告:myProject-libs/release/libboost_regex-mt-s-1.50.0.a(cpp_regex_traits.o):duplicatesection`.data$_ZZN5boost16cpp_regex_traitsIcE21get_catalog_name_instEvE6s_name[boost::cpp_regex_traits::get_catalog_name_inst()::s_name]'hasdifferentsize我怀疑原因可能是boost库的编译选项与我在项目中使用的选项不同,但我

c++ - 错误 : 'std::this_thread' has not been declared

我尝试使用std::this_thread::sleep_for()函数但出现错误错误:“std::this_thread”尚未声明。包含标志_GLIBCXX_USE_NANOSLEEP。还需要什么来强制它工作?MinGW==>gcc版本4.7.2(GCC)中南合作:#includeintmain(){std::this_thread::sleep_for(std::chrono::seconds(3));}命令行:g++-D_GLIBCXX_USE_NANOSLEEP-std=gnu++0xssce.cpp-ossce.exe编译结果:ssce.cpp:Infunction'intm

c++ - "temporary of type ' A ' has protected destructor", 但它的类型是 B

在以下代码中,使用Clang8.0.0+和-std=c++17编译,使用B{}创建派生类实例会报错错误:'A'类型的临时对象具有protected析构函数。当临时文件的类型为B(因此应该有一个公共(public)析构函数)时,为什么A会出现在此消息中?https://godbolt.org/z/uOzwYaclassA{protected:A()=default;~A()=default;};classB:publicA{//canalsoomitthese3lineswiththesameresultpublic:B()=default;~B()=default;};voidfoo(

c++ - Qt Creator编译错误 "::swprintf and::vswprintf has not been declared"

到目前为止,我已经在visualstudio中编写了所有代码,现在我需要向其中添加一些UI,因此我将使用Qt。所以我在我的项目中添加了每个文件(主类除外),然后尝试使用Qt编译它。因为我使用了一些c++0x特性,所以我不得不将这一行添加到项目文件中:QMAKE_CXXFLAGS+=-std=c++0x然后我尝试编译它。只有两个错误(可能还有更多,但编译器在这两个上停止)Infileincludedfromd:\qt\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/postypes.h:42,fromd:\qt\mingw\bin\

c++ - 错误 : '' has not been declared

我正在尝试实现链表,但在编译时出现错误:intSLLst.cpp:38:error:‘intSLList’hasnotbeendeclaredintSLList看起来好像已经向我声明了,所以我真的很困惑。intSLLst.cpp#include#include"intSLLst.h"intintSLList::deleteFromHead(){}intmain(){}intSLLst.h#ifndefINT_LINKED_LIST#defineINT_LINKED_LIST#includeclassIntSLLNode{intinfo;IntSLLNode*next;IntSLLNod

C++:可以在构造函数中初始化 boost::scoped_ptr 吗?

boost::scoped_ptr类型的类成员可以在类的构造函数中初始化吗?怎么样?(不在初始化列表中) 最佳答案 是的。你可以使用reset()成员函数。classfoo{public:foo(){p.reset(newbar());}private:boost::scoped_ptrp;}; 关于C++:可以在构造函数中初始化boost::scoped_ptr吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverf