草庐IT

clnt_call

全部标签

c++ - 错误 C4996 : 'std::_Copy_impl' : Function call with parameters that may be unsafe

我知道这个问题在SO中被问过很多次,但这是与其他问题的不同。CompilerError:FunctioncallwithparametersthatmaybeunsafeVisualStudioWarningC4996xutility(2227):warningC4996:'std::_Copy_impl'失败的代码片段DWORDdwNumberOfNames=pExportDirectory->NumberOfNames;LPDWORDdwNames=(LPDWORD)((LPBYTE)hDLL+pExportDirectory->AddressOfNames);std::vecto

c++ - 铛++ : error: call to 'partition' is ambiguous

#include#includetemplateBidirectionalIteratorpartition(BidirectionalIteratorfirst,BidirectionalIteratorlast,UnaryPredicatepred){while(first!=last){while(pred(*first)){++first;if(first==last)returnfirst;}do{--last;if(first==last)returnfirst;}while(!pred(*last));std::swap(*first,*last);++first;}re

C++ 继承 : Calling virtual method when it has been overridden

我正在尝试构建一个可以在单独的线程中运行(即执行它的run()函数)的service对象。这是服务对象#include#include#include#includeclassservice:publicboost::noncopyable{public:service():stop_(false),started_(false){}virtual~service(){stop();if(thread_.joinable()){thread_.join();}}virtualvoidstop(){stop_=true;}virtualvoidstart(){if(started_.lo

c++ - std::call_once,应该什么时候用?

std::call_oncefunction,在C++11中引入,确保可调用对象以线程安全的方式被恰好调用一次。因为这可以通过其他方式实现-什么时候应该使用std::call_once?它旨在解决什么类型的问题?请举例说明。 最佳答案 示例:我将它用于libcURL从网站检索http(s)数据。在libcURL中,您必须执行one-timeglobalinitialization在你能够使用图书馆之前。鉴于初始化是不是线程安全的,但从网站请求数据是线程安全的,我使用call_once只调用我的初始化一次,无论在什么线程中以及是否它被

c++ - 调试断言失败表达式 : _pFirstBlock == pHead using OpenCV and C++ trying to call SurfFeatureDetector

我在使用OpenCV的C++中有这个函数:vectortest(Matimg){intminHessian=400;SurfFeatureDetectordetector(minHessian);vectorvKeypoints;detector.detect(img,vKeypoints);returnvKeypoints;}当我在主方法中调用此函数时,一切正常。intmain(int,char**argv){//pathtoaimage-filechar*input="image.jpg";//readimageintoMatimgMatimg=imread(input,CV_LO

c# - C++ Interop : How do I call a C# class from native C++, 类是非静态的吗?

我有一个用nativeC++编写的大型应用程序。我还有一个C#类需要调用。如果C#类是静态的,那将是微不足道的(网络上有很多示例)-只需编写混合的C++/CLI包装器,导出接口(interface),即可完成。但是,C#类是非静态的,并且不能更改为静态的,因为它有一个接口(interface)(如果您试图将C#类设为静态,编译器将生成错误)。以前有没有人遇到过这个问题-如何将非静态C#类导出到nativeC++?更新2010-11-09最终解决方案:尝试使用COM,效果很好,但不支持结构。所以,我选择了C++/CLI包装器,因为我绝对需要能够在C++和C#之间传递结构。我根据此处的代码

c++ - 如何影响_calling_函数的值返回?

我希望能够强制执行“双重返回”,即拥有一个强制从其调用函数返回的函数(是的,我知道并不总是真正的调用函数等)显然我希望能够通过操纵堆栈来做到这一点,并且我认为至少以某种不可移植的机器语言方式是可能的。问题是这是否可以相对干净和便携地完成。给个具体的代码来填,我要写函数voidfoo(intx){/*magic*/}使得下面的函数intbar(intx){foo(x);/*longcomputationhere*/return0;}返回,比方说,1;并且不执行长计算。假设foo()可以假设它只被带有bar签名的函数调用,即int(int)(因此明确知道它的调用者返回类型是什么).注意事项

C++ 继承 : Calling Base Class Constructor In Header

假设类Child是类Parent的派生类。在一个五文件程序中,我如何在Child.h中指定我想调用Parent的构造函数?我认为header中的以下内容不合法:Child(intParam,intParamTwo):Parent(Param);在这种情况下,Child.cpp的构造函数语法应该是什么样的? 最佳答案 在Child.h中,您只需声明:Child(intParam,intParamTwo);在Child.cpp中,您将拥有:Child::Child(intParam,intParamTwo):Parent(Param){

c++ - 并发 std::call_once 调用

有人能解释一下为什么这个程序中的两个线程(当使用VisualStudio2012/2013附带的编译器编译时)在两个std::call_once调用都被执行之前被阻塞吗?另一个VisualStudio错误(如果使用GCC编译时它的行为符合预期)?有人可以提出解决方法吗?想象一下我为缩小问题范围所经历的所有痛苦,请大发慈悲。#include#include#include#includenamespace{std::once_flagdid_nothing;voiddo_nothing(){}voidsleep_shorter_and_do_nothing_once(){std::thi

c++ - 为什么 boost::call_traits<T>::param_type 是枚举类型的引用?

基本的C++03枚举类型只是一个具有奇特名称的整数值,因此我希望按值传递它....出于这个原因,我还期望boost::call_traits::param_type与T=SomeEnum确定最有效的传球方式T是按值(value)。从boost文档中查看CallTraits:Definesatypethatrepresentsthe"best"waytopassaparameteroftypeTtoafunction.当我使用boost::call_traits::param_type时与T=SomeEnum它确定SomeEnum应该通过引用传递。我也期待C++11classenums也