草庐IT

qmake-variable-reference

全部标签

c++ - 对 `boost::chrono::system_clock::now()' 的 undefined reference - Boost 和 cpp-netlib

我来这里是为了解决让我感到沮丧的情况。很多。首先,我在Windows上,我使用MinGW作为编译器(C++)。我在让程序使用cpp-netlib和SSL(尝试发布到https站点)时遇到了一些问题。我相信一切都井井有条,除了这个一直在逃避我的错误。C:\boost_1_50_0\boost_1_50_0\stage\lib\libboost_thread-mgw46-mt-1_50.a(thread.o):thread.cpp||对“boost::chrono::system_clock::now()”的undefinedreference我确信我已经链接到chrono,以及BOOST

c++ - 如何将 std::vector<std::reference_wrapper<T>> 转换为 std::vector<T>

我有一个本地std::vector>现在我想返回其元素的真实拷贝(即std::vector)。有没有比循环更好的方法?例子:std::vectorfoobar(){std::vector>refsToLocals;/*dosmthwithrefsToLocals*/std::vectorcopyOfLocals;for(autolocal:refsToLocals)copyOfLocals.insert_back(local.get());returncopyOfLocals;} 最佳答案 看来,最明显的方法是构造一个std::ve

c++ - 微优化 : iterating with local variable vs. 类成员

我认为如果我将迭代变量声明一次作为类成员,我会节省一些时间:structFoo{inti;voidmethod1(){for(i=0;i然而,这似乎快了20%structFoo{voidmethod1(){for(inti=0;i在这段代码中voidloop(){//Arduinoloopsfoo.method1();foo.method2();}您能解释一下性能差异吗?(我需要在Arduino上运行许多简单的并行“进程”,这种微优化会产生影响。) 最佳答案 当您在循环内声明循环变量时,它的范围非常狭窄。编译器可以随时将其保存在寄存

我的类中的 c++ condition_variable wait_for 谓词,std::thread <unresolved overloaded function type> error

我想在我的类中使用一个线程,然后该线程需要使用一个condition_variable,条件变量将被阻塞,直到一个谓词被更改为true。代码如下所示:classmyThreadClass{boolbFlag;threadt;mutexmtx;condition_variablecv;boolmyPredicate(){returnbFlag;}intmyThreadFunction(intarg){while(true){unique_locklck(mtx);if(cv.wait_for(lck,std::chrono::milliseconds(3000),myPredicate)

c++ - 对类模板成员函数的 undefined reference

我想在模板类方法中使用迭代器。这是我的代码:(testclass.h)templateclassTestClassX{public:voidgen(typenamecontainer::iteratorfirst);};和文件testclass.cpp:templatevoidTestClassX::gen(typenamecontainer::iteratorfirst){}当我尝试运行它时:TestClassX>testx;testx.gen(it);我得到一个错误:Error:undefinedreferenceto`TestClassX>>::gen(__gnu_cxx::__

c++ - qmake 中的编译器范围值

qmake提供了几个内置的平台作用域,允许一个项目文件根据当前平台执行不同的操作:win32{...}unix{...}mkspecs目录中的所有平台规范也可用于测试各种平台/编译器组合,例如linux-g++{...}win32-g++{...}win32-msvc2003{...}但是,我似乎找不到只测试编译器(没有操作系统)的方法#Thisdoesnotworkg++{...}msvc{...}有没有一种方法可以做到这一点而不必列出所有组合(linux-g++|win32-g++|cygwin-g++|...{})?如果这不可能,是否有充分的理由? 最

c++ - 键入对 `cv::fastFree(void*)' 的 undefined reference

我在Win8、最新的MinGW和EclipseKeplerR1、CDT上开始了opencv2.4.7的教程。C++编译器包含引用[path-to-opencv]\open247\build\include。在MinGWC++链接器中,我添加了库路径[path-to-opencv]\open247\build\x64\vc11\lib。vc11目录包含我读过的VisualStudio库。用MinGW编译它们还可以吗?我为这个示例添加了核心和highgui库(我认为我们需要的不只是那些)。但是,对于下面这个简单的空闲代码,我引发了以下编译错误。#include#includeusingna

c++ - std::reference_wrapper 的大小有任何保证吗?

考虑这样一种情况,我有足够的存储空间来托管void*,因此可以就地构造一个指针。是否可以保证相同的存储空间足够大以始终存储std::reference_wrapper?有点(出于我的想法,只是为了理解我的意思):std::aligned_storage_tstorage;//...intvalue=0;new(&storage)std::reference_wrapper{value};从快速而肮脏的测试中,我发现在我的机器上这是有效的,即std::reference_wrapper的大小适合void*。但是,在不同的平台上可能会出现这种情况。同时,我在标准中找不到关于std::ref

c++ - "variable tracking"占用了我的编译时间!

我有一个自动生成的文件,看起来像这样......staticvoiddo_SomeFunc1(void*parameter){//Dostuff.}//Continuesonforanother4000functions...voiddispatch(intid,void*parameter){switch(id){case::SomeClass1::id:returndo_SomeFunc1(parameter);case::SomeClass2::id:returndo_SomeFunc2(parameter);//Thiscontinuesforthenext4000cases.

c++ - 这个 AnonymousClass(variable) 声明中到底发生了什么?

尝试编译:classAnonymousClass{public:AnonymousClass(intx){}};intmain(){intx;AnonymousClass(x);return0;}从MSVC生成错误:foo.cpp(13):errorC2371:'x':redefinition;differentbasictypesfoo.cpp(12):seedeclarationof'x'foo.cpp(13):errorC2512:'AnonymousClass':noappropriatedefaultconstructoravailableg++的错误信息类似:foo.cpp