草庐IT

method_called

全部标签

c++ - C++ 中 "extension methods"的标准化提案在哪里?

我忘记了用于描述我大约一年前(也许更久)前看到的提案中使用的功能的确切术语。它看起来类似于C#扩展方法,因为可以使用类成员语法调用定义为类接口(interface)一部分的全局函数。非常非常愚蠢的例子:classFoo{public:voidOne();};voidTwo(Foo&);intmain(){Foof;f.One();f.Two();//ThiswasvalidintheproposalIsaw}我确信我的代码示例已经过时了,但我更多地使用它来尝试传达我记得看到的功能。我是完全离开这里还是有C++的提案引入了这种机制?如果是这样,有人可以向我指出该提案及其状态/时间表吗?

c++ - boost::call_traits - 为什么 gcc 为此给出 false?

示例:#include#include#includeboost::call_traits::param_typef(){return1;}intmain(){std::cout::param_type>::value::value问题:除非我做错了什么,我想我应该为两者都得到true,但是gcc4.7.0为后者输出false。有什么我想念的吗? 最佳答案 非类类型的右值永远不是const限定的。只有类类型的右值可以是const限定的。因此,即使函数f被声明为返回一个constint,即使函数f的类型是constint(),调用表达

c++ - 将 googlemock EXPECT_CALL 与 shared_ptr 一起使用?

我有一个测试可以很好地使用原始指针,但我无法让它与std::shared_ptr一起工作。类是这样的:classMyClass{MyClass(SomeService*service);voidDoIt();}我的测试代码是这样的:classMyClassTests:public::testing::Test{public:MyClassTests():myClass_(newMyClass(&service_)){}protected:SomeServiceFakeservice_;MyClassSharedPointermyClass_;};TEST_F(MyClassTests,

C++ WINAPI : How to kill child processes when the calling (parent) process is forcefully terminated?

谁能告诉我如何在调用(父)进程被强制终止时终止子进程?顺便说一句,我无法更改子应用程序的源代码。我检查了StackOverflow中的现有线程,JobObject似乎是正确的方法。但是当我测试它时(使用控制台应用程序调用notepad.exe),我发现当控制台应用程序退出时,记事本没有。我使用CreateProcess生成新进程。我也看到有人说在父进程和子进程之间建立一个管道就可以了,但我还没有尝试过。如果有人能给我一些提示,我将不胜感激。更新:如果没有,WINAPIAssignProcessToJobObject将无法工作|在CreatProcess中创建CREATE_BREAKAW

C++ 错误 : reference to non-static member function must be called

我正在尝试创建一个类来抽象libuv网络功能的一些基本行为。#defineTCP_BACKLOG256class_tcp{uv_tcp_t*tcp=NULL;public:~_tcp(){deletetcp;}voidlisten_uv_listen_uv_connection_cb(uv_stream_t*stream,intstatus){printf("NEWCONNECTION\n");}voidlisten(constchar*host,intport){tcp=newuv_tcp_t();uv_tcp_init(uv_default_loop(),tcp);sockaddr

c++ - 概念 : checking signatures of methods with arguments

我一直在研究概念。这是一个最小的例子,我试图在其中创建一个基于方法签名的概念:templateconceptboolmyConcept(){returnrequires(Ta,inti){{a.foo()}->int;{a.bar(i)}->int;};}structObject{intfoo(){return0;}intbar(int){return0;}};static_assert(myConcept(),"ObjectdoesnotadheretomyConcept");令我惊讶的是,编写{a.bar(int)}->int不起作用,所以我求助于向requires表达式添加一个额

c++ - 使用 C++0x : call to deleted constructor of 时的 clang++ 错误消息

您好,我已经将我的Xcode升级到4.2版,并将clang++升级到以下版本:Appleclangversion3.0(tags/Apple/clang-211.10.1)(basedonLLVM3.0svn)Target:x86_64-apple-darwin11.2.0Threadmodel:posix当尝试使用clang-std=c++0x编译以下代码时#include#include#includeclassilpConstraintImpl{public:virtual~ilpConstraintImpl(){}};classilpConstraint{public:ilpC

c++ - std::reverse_copy "error: function call has aggregate value"

#include#include#include#includeusingnamespacestd;intmain(){intarrA[]={1,2,3,4,5,6,7,8,9};vectorvecIntA(arrA,arrA+sizeof(arrA)/sizeof(arrA[0]));vectorvecIntB(vecIntA.size());//copy((vecIntA.rbegin()+3).base(),(vecIntA.rbegin()+1).base(),vecIntB.begin());//OKvector::iterators=(vecIntA.rbegin()+3)

c++ - 模板调用 : Actual specialization not called

#includeusingnamespacestd;templatevoidtest(){coutvoidtest(){cout();//expectedoutput2butactualoutput1}为什么输出是1而不是2? 最佳答案 test(注意:末尾没有括号)会产生您期望的结果。写成test用“不带参数并返回std::string的函数”类型实例化模板 关于c++-模板调用:Actualspecializationnotcalled,我们在StackOverflow上找到一个类似

c++ - CRTP 静态多态性 : Using the Base Class to Call Derived Methods

C++中virtual的主要好处之一是能够使用基类(指针或引用)调用派生方法。我正在阅读usingCRTPtoimplementstaticpolymorphism,但我不明白如何使用这种技术实现上面提到的内容,因为当需要模板时,我无法将函数声明为采用Base类型。在我看来,文章中描述的内容可以通过简单地使用函数重载来实现,所以我确信这种技术一定有更多。(PS:在对thisquestion的回答的评论中提到了这个确切的问题,但不幸的是没有人回复它:“vtables真正提供的是使用基类(指针或引用)来调用派生方法。你应该在这里展示它是如何用CRTP完成的。”)这是我的最小代码,它给出了错