草庐IT

memory_block

全部标签

c++ - OpenCv图像 block ,大小错误?

我有一个函数,可以使用C++和OpenCv将图像分成block以进行进一步处理。这是我的代码:voidimageSplit(Matimage){intblockNumber=8;//gettheimagedataintheight=image.rows;intwidth=image.cols;//sethowmanyblocksandcreatevectortostorecv::SizesmallSize(height/blockNumber,width/blockNumber);std::vectorsmallImages;for(inty=0;y它适用于更大的区域(512x512有

c++ - 线程构建 block : Deadlocks because all threads used up

在英特尔线程构建block框架中,如何确保所有线程不忙于等待其他线程完成。例如考虑以下代码,#include#include#include#include#includestd::futurerun_something(std::functionfunc,boolb){autotask=std::make_shared>(std::bind(func,b));std::futureres=task->get_future();tbb::task_groupg;g.run([task](){(*task)();});returnres;};intmain(){tbb::parallel

c++ - block 范围静态的析构函数可以被调用几次?

我刚刚读了this有关当前boost::mutex实现背后实际原因的文章,并注意到以下短语:Block-scopestaticshavetheadditionalproblemofapotentialraceconditionon"thefirsttimethrough",whichcanleadtothedestructorbeingrunmultipletimesonpopularcompilers,whichisundefinedbehaviour—compilersoftenusetheequivalentofacalltoatexitinordertoensurethatde

c++ - 毫秒 mpi 错误 : unable to allocate launching block

我使用msmpi在VS2015中创建了简单的控制台程序。#include#include#includeintmain(intargc,char**argv){intrank=0,size=0;MPI_Init(&argc,&argv);/*startsMPI*/MPI_Comm_rank(MPI_COMM_WORLD,&rank);/*getcurrentprocessid*/MPI_Comm_size(MPI_COMM_WORLD,&size);if(rank==0){charhelloStr[]="HelloWorld";//MPI_Send(helloStr,_countof(

c++ - 是否可以在 VS2008 中的预处理器指令 block (如 #ifndef ... #endif)中启用智能感知

在C++库中工作时,我注意到在诸如“#ifndefCLIENT_DLL...#endif”之类的指令block中时,我没有获得任何智能感知。这显然是因为定义了“CLIENT_DLL”。我意识到我可以通过简单地注释掉指令来解决这个问题。是否有任何智能感知选项可以在不考虑指令评估的情况下启用智能感知? 最佳答案 得到你想要的,你会失去很多。VisualC++IntelliSense基于几个主要假设1.你想要好的/可用的结果。2.您当前的IntelliSensecompiland将显示与您当前所在的“配置”相关的信息。因为您当前的配置具有

c++ - 如何防止 QTextDocument block 或框架中的分页符?

是否可以防止在QTextDocument中表格内的任何地方分页?在我的QTextDocument中,我有大量从小图像block创建的大图像。添加大图像似乎是一种资源浪费,因此一个明显的解决方案似乎是创建一个表,将小图像放在每个单元格中。问题是现在这些表格在每一行之后可以有分页符。我知道防止它的唯一方法是为每个表/框架格式调用setPageBreakPolicy(),但这需要在每个较大的图像之前强制分页。我只想在必要时使用这些分页符(大图放不下)。有没有可能做我想做的事? 最佳答案 对于QTextTable,您可以通过将QTextTa

c++ - "static functions with block scope are illegal"错误取决于初始化样式?

我有一个类Library,其中包含一个结构Transaction,该结构有一个类型为Patron的成员变量。classPatron{public:Patron(){}};classLibrary{public:structTransaction{Patronp;Transaction(Patronpp):p(pp){}Transaction();};};对于Transaction的默认构造函数,我有一个函数default_transaction()返回对静态对象的const引用,正如Stroustrup在“编程-原则和实践”中所推荐的使用C++”(第324页);推理:避免在构造函数代码

c++ - 标记为可能丢失 block 的静态指针是否损坏?

在阅读了有关Valgrind的“可能丢失”block消息后,它们似乎很糟糕。我收到静态指针类成员的错误。我想验证我们的代码没有任何问题。我从Valgrind得到这个:==27986==76bytesin1blocksarepossiblylostinlossrecord370of1,143==27986==at0x4C247F0:operatornew(unsignedlong)(vg_replace_malloc.c:319)==27986==by0x107CFEE8:std::string::_Rep::_S_create(unsignedlong,unsignedlong,std

C++ 原子 : would function call act as memory barrier?

我正在阅读这篇文章MemoryOrderingatCompileTime从中说:Infact,themajorityoffunctioncallsactascompilerbarriers,whethertheycontaintheirowncompilerbarrierornot.Thisexcludesinlinefunctions,functionsdeclaredwiththepureattribute,andcaseswherelink-timecodegenerationisused.Otherthanthosecases,acalltoanexternalfunction

c++ - memory_order_seq_cst 如何与非原子操作同步?

如果使用单个原子变量和std::memory_order_seq_cst,是否保证非原子操作不会被重新排序?例如,如果我有std::atomicquux={false};voidfoo(){bar();quux.store(true,std::memory_order_seq_cst);moo();}是bar()保证在调用store之后不会重新排序,并且moo()在调用之前不会重新排序store,只要我使用std::memory_order_seq_cst,至少从另一个线程的角度来看?或者,换句话说,如果从另一个线程运行,以下假设是否有效?if(quux.load(std::memor