草庐IT

make_member_delegate

全部标签

c++ - Lambda 捕获列表 : capturing object's member field by value not possible without capturing the whole object?

下面的代码voidCMainWindow::someMethod(constCLocationsCollection&parentItem){autof=[this,parentItem.displayName](){};}给我一​​个错误:errorC2143:syntaxerror:missing']'before'.'如果我想通过ref捕获parentItem.displayName,我会为它创建一个非依赖别名标识符:constQString&name=parentItem.displayName;autof=[this,&name](){};//Orshoulditbe[thi

c++ - 如何让 boost::make_shared 成为我类(class)的 friend

我编写了一个带有protected构造函数的类,因此只能使用静态create()函数生成新实例,该函数将shared_ptr返回我的类。为了提供有效的分配,我想在create函数中使用boost::make_shared,但是编译器提示说我的类构造函数在boost::make_shared中受到保护。我决定让我的boost::make_shared成为我类的friend,但我对语法感到困惑。我试过了templatefriendboost::shared_ptrboost::make_shared(constConnectionManagerPtr&,conststd::string&)

C++11 : error: ‘begin’ is not a member of ‘std’

我正在尝试执行以下操作:source=newint[10];dest=newint[10];std::copy(std::begin(source),std::end(source),std::begin(dest));但是,编译器报如下错误。copy.cpp:5434:14:error:‘begin’isnotamemberof‘std’copy.cpp:5434:44:error:‘end’isnotamemberof‘std’copy.cpp:5434:72:error:‘begin’isnotamemberof‘std’我已经包含了所需的代码中的header。有人可以帮我解决这

c++ - "single allocation"对 boost::make_shared 意味着什么

在make_shared的boost文档中,它说:Besidesconvenienceandstyle,suchafunctionisalsoexceptionsafeandconsiderablyfasterbecauseitcanuseasingleallocationforboththeobjectanditscorrespondingcontrolblock,eliminatingasignificantportionofshared_ptr'sconstructionoverhead.我不明白“单一分配”的意思,是什么意思? 最佳答案

c++ - VS2010 : "Cannot find the resource compiler DLL. Please make sure the path is correct."

我一直在关注theForger'swin32APItutorial,然后我决定打开menu_one.rc文件以从VS2010中查看其内容,但我收到此错误:我已经仔细检查了这两个位置,但实际上这两个文件都不存在。我仅有的rcdll.dll拷贝位于:C:\ProgramFiles(x86)\MicrosoftSDKs\Windows\v7.0A\Bin\rcdll.dllandC:\ProgramFiles(x86)\MicrosoftSDKs\Windows\v7.0A\Bin\x64\rcdll.dll我试过做repairinstalloftheWindowsSDK,但这并没有解决问题

c++ - 使用 make_unique 语句重新分配 unique_ptr 对象 - 内存泄漏?

我不明白下面的语句会做什么(特别是第二行)?autobuff=std::make_unique(128);buff=std::make_unique(512);第二次调用make_unique后跟赋值运算符会释放第一次调用分配的内存,还是会发生内存泄漏?我必须使用buff.reset(newint[512]);吗?我调试了它,但没有发现任何operator=被调用,也没有发现任何析构函数被调用(通过unique_ptr)。 最佳答案 移动赋值运算符被调用,它执行if(this!=&_Right){//different,dothes

c++ - '&' : illegal operation on bound member function expression

这个问题在这里已经有了答案:Printaddressofvirtualmemberfunction(5个答案)关闭7年前。当我尝试从具有主要功能的单个cpp文件时,这有效,sprintf(smem_options,"#transcode{vcodec=RV24}:smem{""video-prerender-callback=%lld,""no-time-sync},",(longlongint)(intptr_t)(void*)&cbVideoPrerender);如何在类中将函数参数传递给sprintf?sprintf(smem_options,"#transcode{vcodec

c++ - C++1z 中 std::make_unique 和 std::make_shared 的有用性

在C++17中,我们可以对类模板进行模板类型推导。所以很多make函数可能会过时。make_unique和make_shared怎么样?所以我们可以这样写unique_ptrmyPtr(newMyType());//vsautomyPtr=make_unique();那么我们可以忘记那些功能吗? 最佳答案 unique_ptr和shared_ptr都不能在没有明确提供类型的情况下构造,因为无法区分T*和T[]。编写unique_ptr{newint}格式错误。此外,std::make_shared不仅仅为您构造一个std::shar

c++ - 你推荐什么 GNU make 替代品?

关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。关闭6年前。Improvethisquestion想象一下,您可以为新的C++项目自由选择GNUmake等工具。你会选择什么?有可用的替代品吗?它应该有/是命令行界面“容易”理解易于设置默认的c++项目可能支持src/bin分离,这在Java中很常见可能不会对其他软件/库添加太多依赖平台独立(新)特点:像make一样以人类可读的方式构建规则/模板递归爬行目录并在没有其他目录时应用规则“生成文件”异常配置注意:GNUm

c++ - std::is_member_function_pointer 不适用于 noexcept 成员函数

我在使用std::is_member_function_pointer时遇到问题。据我所知,在给定noexcept成员函数时它不起作用。我在标准中找不到任何声明它不适用于noexcept合格成员函数的内容。问题示例:#includeclassA{public:voidmember()noexcept{}};intmain(){//failsatcompiletimeifA::memberisadatamemberandnotafunctionstatic_assert(std::is_member_function_pointer::value,"A::memberisnotamemb