草庐IT

member-variables

全部标签

c++ - std::condition_variable_any 的 libc++ 实现

条件变量应该有关于notify()的单一顺序和unlock_sleep()(在wait()中使用的一个虚构的函数调用,其中互斥锁被解锁并且线程作为一个原子操作序列休眠)操作。使用任意可锁定器实现此目的std::condition_variable_any实现通常在内部使用另一个互斥体(以确保原子性和休眠)如果内部unlock_sleep()和notify()(notify_one()或notify_all())操作彼此之间不是原子的,您冒着一个线程解锁互斥锁、另一个线程发出信号然后原始线程进入休眠状态并且永远不会醒来的风险。我正在阅读std::condition_variable_an

c++ - 无法将 "member pointer to derived class"转换为 "member pointer to base class"

使用指向基类的指针调用类的虚成员函数当然是C++中非常常见的事情。所以我觉得很奇怪,当你有一个成员指针而不是一个普通指针时,似乎不可能做同样的事情。请考虑以下代码:structB{virtualvoidf();};structD:B{virtualvoidf();};structE{Bb;Dd;};intmain(){Ee;//Firstwithnormalpointers:B*pb1=&e.b;//OKB*pb2=&e.d;//OK,BisabaseofDpb1->f();//OK,callsB::f()pb2->f();//OK,callsD::f()//Nowwithmember

C++11/14 : How to remove a pointer-to-member from a type?

在C++11或C++1y/14中:给定一个TC::*形式的指向成员类型的值,我想得到指向类型例如:#includeusingnamespacestd;structT1{staticvoidf(){coutstructV;templatestructV{staticconstexprT1U1::*pm=&U1::x;};templatestructV{staticconstexprT2U2::*pm=&U2::x;};templatevoidf(Wpm){typedef???T;T::f();}intmain(){f(V::pm);f(V::pm);}有没有办法做到这一点?上面的???是

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++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++ - '&' : 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/C++ : is it faster to assign a 0 to an unsigned long variable or to xor the variable with itself?

这个问题不太可能帮助任何future的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visitthehelpcenter.关闭9年前。我意识到差异可以忽略不计,但在尝试将unsignedlong清零时哪个更有效?unsignedlongx;...x=0;--OR--x^=x;泰勒

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

c++ - decltype( (A{}.int_member) ) 的正确结果是什么?

给定类型A的定义:structA{inti;};根据规范[expr.ref](我使用了n4618):(ifE2isnon-reference,)...IfE1isanlvalue,thenE1.E2isanlvalue;otherwiseE1.E2isanxvalue...显然A{}.i是xvalue;还考虑到[dcl.type.simple]:(fordecltype(e),)—...ifeisanunparenthesizedid-expressionoranunparenthesizedclassmemberaccess...—otherwise,ifeisanxvalue,de

c++ - 错误 C2039 : 'find' : is not a member of 'std'

我刚遇到一个奇怪的错误,说find不是std的成员。errorC2039:'find':isnotamemberof'std'errorC3861:'find':identifiernotfound基本上,我想查找是否可以在vector中找到一个字符串知道为什么会这样吗?代码帮助告诉我在std中有find方法。这基本上就是我所做的:#include"OperatorUtil.h"#include#include#include#include#includeusingnamespacesaeConfig;namespaceoperatorUtil{boolisIn(constFilte