草庐IT

this-reference

全部标签

Retrieving Git references 问题 Jenkins选择分支

RetrievingGitreferences问题Jenkins选择分支用Jenkins构建时,选择分支出现RetrievingGitreferences错误,如下图所示:可能跟你安装的插件有关系,我当时就是因为装了GerritTrigger这个插件后导致无法选择分支。解决办法:1.先去Jenkins插件管理处卸载这个插件,这里卸载并不能卸载干净,还需去Jenkins安装目录下手动删除这个插件程序2.我当时的Jenkins安装目录默认在C盘,路径是C:\ProgramData\Jenkins.jenkins\plugins,找到GerritTrigger这个插件程序,然后删除掉。(删除之前需停

c++ - Qt 在构建移动到线程的 QObject 时将 "this"作为父级传递

阅读文档后我发现了这个:ThechildofaQObjectmustalwaysbecreatedinthethreadwheretheparentwascreated.Thisimplies,amongotherthings,thatyoushouldneverpasstheQThreadobject(this)astheparentofanobjectcreatedinthethread(sincetheQThreadobjectitselfwascreatedinanotherthread).我不太确定这意味着什么,所以我举了几个例子,想知道这适用于什么地方。A.classMyT

c++ - 持有大量共享状态的访问者类 : best way to implement reference semantics?

这个问题大致基于使用Visitor的Boost.Graph库(BGL)-like模式来定制递归(搜索)算法。BGL按值传递访问者对象(类似于STL函数对象)和documentation州Sincethevisitorparameterispassedbyvalue,ifyourvisitorcontainsstatethenanychangestothestateduringthealgorithmwillbemadetoacopyofthevisitorobject,notthevisitorobjectpassedin.Thereforeyoumaywantthevisitorto

C++11,枚举类,g++ 的 undefined reference ,与 clang++ 一起工作

我使用了新的C++11“枚举类”类型,并在使用g++时观察到“undefinedreference”问题。这个问题不会发生在clang++中。我不知道是我做错了什么还是g++错误。重现问题的代码是:(4个文件:enum.hpp、enum.cpp、main.cpp和Makefile)//file:enum.hppenumclassMyEnum{val_1,val_2};templatestructFoo{staticconstMyEnumvalue=MyEnum::val_1;};templatestructFoo{staticconstMyEnumvalue=MyEnum::val_2

c++ - 对 'cv::viz::Viz3d::Viz3d(std::string&const)' 的 undefined reference

我已经使用qtcreator运行了我的opencv代码,当我尝试使用Viz库时得到了这个答案。代码:#include#include#include#include#include///Createawindowviz::Viz3dmyWindow("VizDemo");///StarteventloopmyWindow.spin();///Eventloopisoverwhenpressedq,Q,e,Eprintf("Firsteventloopisover\n");///Accesswindowviaitsnameviz::Viz3dsameWindow=viz::getWind

c++ - GCC 向依赖默认构造函数的模板化类中的静态数据成员给出 "undefined reference"错误

我遇到了类似的问题:"undefinedreference"tostaticfieldtemplatespecialization但他们使用的解决方法对我不起作用。我有一个带有静态数据成员的CRTP类,其中之一是std::mutex。不幸的是,GCC(4.8.2)的链接器给我这个互斥锁的“undefinedreference”错误。Clang(3.4)没有。有解决方法吗?最初的问题(上面链接)在静态数据成员上调用了复制构造函数,迫使GCC发出一个符号,但是由于我的数据成员是std::mutex,所以这不是一个选项——复制构造函数被删除,并且有没有参数构造函数。我只是被冲洗了吗?我认为问

c++ - 使用 CMake 对 `shm_open' 的 undefined reference

我在Ubuntu14.04下使用CMake配置我的项目。我需要使用第3方库(比如stuff.so)。在CMakeLists.txt中,我使用TARGET_LINK_LIBRARIES链接素材库。但是,我得到一个错误:DIR_TO_LIB/stuff.so:-1:error:undefinedreferenceto`shm_open'我试图将这些标志放在CMakeLists.txt中,但没有成功:set(CMAKE_EXE_LINKER_FLAGS"${CMAKE_EXE_LINKER_FLAGS}-lrt")set(CMAKE_CXX_FLAGS"${CMAKE_CXX_FLAGS}-

c++ - 创建线程并让 "this"指针从构造函数中逃逸总是安全的吗?

我对以下代码感到困惑(来自PreferUsingActiveObjectsInsteadofNakedThreads):classActive{public:classMessage{//baseofallmessagetypespublic:virtual~Message(){}virtualvoidExecute(){}};private://(suppresscopyingifinC++)//privatedataunique_ptrdone;//lesentinelmessage_queue>mq;//lequeueunique_ptrthd;//lethreadprivate

c++ - 为继承 enable_shared_from_this 的类获取 unique_ptr

通常我更喜欢从工厂返回unique_ptr。最近我遇到了为继承enable_shared_from_this的类返回unique_ptr的问题。此类的用户可能会意外调用shared_from_this(),尽管它不属于任何shared_ptr,这会导致std::bad_weak_ptr异常(或C++17之前的未定义行为,通常作为异常实现)。代码的简单版本:classFoo:publicenable_shared_from_this{stringname;Foo(conststring&_name):name(_name){}public:staticunique_ptrcreate(c

c++ - 对静态常量整数类型的 undefined reference

我对静态整数常量有一个奇怪的行为:#include#includeclassTest{public:staticconstuint32_tMagic=0x1123;};classDataStream{public:templateDataStream&operator我知道这些常量应该在.cpp类之外定义为constuint32_tTest::Magic;但奇怪的是,上面的代码在s行下工作正常并且仅在Magic时产生错误与模板一起使用operator直接。更多错误undefinedreferenceto'Test::Magic'与GCC一起出现,但不是MSVC.问题是为什么我要定义Te