jjzjj

execution

全部标签

c++ - 具有可变高阶函数的重载分辨率

假设我有一个可变的高阶函数templatevoidexecution(Ffunc,Args&&...args){func(std::forward(args)...);}然后对于这个重载集voidf(){}voidf(intarg){}过载分辨率将为impossibleintmain(){execution(f,1);execution(f);return0;}然而,如果只提供两者之一,程序compiles为什么会这样?为什么模板参数推导失败?如果我从集合中删除f()并将其替换为f(arg,arg2),仍然会有一个problem.是否有解决方法,或者我是否总是必须providethet

c++ - 继承层次结构 : Constructor & Destructor execution sequence

在这里http://www.parashift.com/c++-faq-lite/multiple-inheritance.html[25.14]节说Theveryfirstconstructorstobeexecutedarethevirtualbaseclassesanywhereinthehierarchy.我尝试使用以下程序验证它:A(purevirtual)|B|C(virtual)/\(virtual)ED\/F|G(purevirtual)|H每个类都有一个c'tor和virtuald'tor。输出如下:ABCEDFGH~H~G~F~D~E~C~B~APressanyke

c++ - 使用 'g++' 结果为 "warning: will never be executed"

我继承了一个C++项目。我在RHELbuild5.5与GCC4.1.2通过makefile。该项目很大(数百个文件),总的来说代码还不错。然而,在编译过程中,我经常收到一个GCC警告,上面写着(prefix"/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2"):/bits/allocator.h:Inconstructor‘std::allocator::allocator()[with_Tp=char]’:/bits/allocator.h:97:warning:willneverbeexecuted

c++ - (C++ 线程): Creating worker threads that will be listening to jobs and executing them concurrently when wanted

假设我们有两个worker。每个worker都有一个0和1的id。还假设我们一直有工作到达,每个工作也有一个标识符0或1指定哪个worker必须做这个工作。我想创建2个线程,它们最初是锁定的,然后当两个作业到达时,解锁它们,每个线程都完成它们的工作,然后再次锁定它们,直到其他作业到达。我有以下代码:#include#include#includeusingnamespacestd;structjob{threadjobThread;mutexjobMutex;};jobjobs[2];voidexecuteJob(intworker){while(true){jobs[worker].

c++ - 为什么 C++ 标准 1.9/5 谈论 "possible execution sequences"?

根据C++03标准1.9/5Aconformingimplementationexecutingawell-formedprogramshallproducethesameobservablebehaviorasoneofthepossibleexecutionsequencesofthecorrespondinginstanceoftheabstractmachinewiththesameprogramandthesameinput.我不明白“作为其中一个”部分。如果我有一个特定的程序和一个特定的输入,并且我的程序不包含未定义的行为,为什么可观察到的行为会有所不同?“一种可能的执行顺

c++ - 追踪器 : error TRK0002: Failed to execute command

我在尝试在作为服务运行的buildAgent上构建我的项目时遇到此错误,有人有解决方案吗?TRACKER:errorTRK0002:Failedtoexecutecommand:""C:\ProgramFiles(x86)\MicrosoftVisualStudio14.0\VC\bin\amd64\CL.exe"@C:\BuildAgent\temp\buildTmp\tmpfde187c5fd8a42299ab4d18e25e0c9fe.rsp".Theoperationidentifierisnotvalid.在命令行中构建项目时(使用“_IsNativeEnvironment”

c++ - 比较相同代码在不同输入下的执行路径

我正在调试一个非常复杂的C++函数,它在某些输入下给出了一些意想不到的结果。我想比较不同输入下的代码执行情况,以便找出导致我出错的部分。可以比较代码执行路径的工具正是我要找的。如果存在这样的工具,请告诉我。或者如果有一些技术我可以用来做同样的事情?为了具体描述我的问题,这里我使用了一个人为的例子。假设这是伪代码中的函数,doublepayTax(doubleincome){if(income给定输入15000,该函数计算出正确的税额,但不知为何输入16000给出了错误的税额。据推测,输入15000和16000会导致函数通过完全相同的执行路径;另一方面,如果它们走不同的路径,那么一定是函

c++ - 运行时不同的执行策略

在C++17中,algorithmheader中的许多函数现在可以采用执行策略。例如,我可以定义和调用这样的函数:templatevoidf1(conststd::vector&vec,conststd::string&elem,ExecutionPolicy&&policy){constautoit=std::find(std::forward(policy),vec.cbegin(),vec.cend(),elem);}std::vectorvec;f1(vec,"test",std::execution::seq);但是我还没有找到在运行时使用不同策略的好方法。例如,当我想根据某

c++ - 给定范围内的完美正方形 : abnormal execution of loops

程序编号1:在给定的a和b范围内,其中ab,我想找出一个数字是否是一个完美正方形,如果是,则打印其根。因此,我编写了如下代码:#include#include#include#includeusingnamespacestd;floatsquaredroot(intn){floatlow=0.0,mid;floathigh=(float)n+1;while((high-low)>0.00001){mid=(low+high)/2;if(mid*mid>a>>b;floatroo=0.0;for(i=a;i对于给定的输入15,输出应该是2。但是,上面的程序没有打印任何值。然而,当我尝试使

c++ - g++ : can't link with a main executable file

我正在开发一个使用统计攻击来破解wepkey的应用程序。当我用我的makefile编译时(如上)我得到这个错误:ld:can'tlinkwithamainexecutablefile'execStatAttack'forarchitecturex86_64clang:error:linkercommandfailedwithexitcode1(use-vtoseeinvocation)make:*[statAttack]Error1我的项目包含那些文件:statAttack.cpp:包含主要功能,使用上面的文件rc4.h+rc4.cpp:具有那些功能#include#include#i