草庐IT

a_very_long_method_name

全部标签

c++ - 为什么 injected-class-name 有时不被视为类模板中的模板名称?

SourceInthefollowingcases,theinjected-class-nameistreatedasatemplate-nameoftheclasstemplateitself:itisfollowedbyitisusedasatemplateargumentthatcorrespondstoatemplatetemplateparameteritisthefinalidentifierintheelaboratedclassspecifierofafriendclasstemplatedeclaration.所以我尝试检查所有3种情况(另外在基本歧义的情况下,尽管我

c++ - mock_method 上的 gmock 编译错误(在 testing::internal::FunctionMocker 中)

当我尝试模拟一个函数时,我遇到了一些奇怪的编译错误。编译器提示复制构造函数有问题。代码片段:classdb_key{public:db_key(void){}explicitdb_key(constchar*buf){}~db_key(void){}};classbar_A{public:explicitbar_A(constdb_key&key):m_key(key){}virtual~bar_A(void){}constdb_key&dbkey(void)const{returnm_key;}private:constdb_keym_key;};classbar_B:bar_A{p

c++ - Very Sleepy 分析器中花括号附近显示的时间测量值代表什么?

我正在使用VerySleepy分析一些C++代码,我注意到在SourceView中,它显示了红色的逐行时间测量值,在某些情况下,只有方法的左花括号或右花括号的行总是有测量值与函数中的其他代码行相比,这些情况非常高。我最初的假设是显示将方法参数压入左大括号堆栈所花费的时间,以及为右大括号弹出堆栈所花费的时间。这是真的吗? 最佳答案 我从VerySleepy的维护者RichardMitton(@grumpydev)在推特上得到了一个答案:“很可能函数已经优化,所以行号与代码不完全匹配更多。也就是说,所有时间都集中在开始时,而不是分散在函

c++ - float、double 和 long double 是否有保证的最小精度?

从我之前的问题“Isfloatingpointprecisionmutableorinvariant?”我收到了一个response其中说,CprovidesDBL_DIG,DBL_DECIMAL_DIG,andtheirfloatandlongdoublecounterparts.DBL_DIGindicatestheminimumrelativedecimalprecision.DBL_DECIMAL_DIGcanbethoughtofasthemaximumrelativedecimalprecision.我查看了这些宏。它们位于标题中。.来自cplusplusreference

c++ - 模板参数可以同时是 int 和 unsigned long 吗?

我有以下代码:#includetemplateclassA{};templateclassB;templateclassB>{};intmain(){B>b;return0;}在这里,B被模板化为int而A被模板化为size_t,它是一个unsignedlong我正在使用的两个编译器。当我使用编译器1(当前编译器)时,一切都按照我期望的方式编译和工作。当使用编译器2(我们正在转向的编译器)时,我收到一个编译器错误,指出B没有采用unsignedlong的模板特化-它已解释3作为unsignedlong因为它需要是A的一个,但是对于B。修复很明显,-只需更改B也采用size_t(或更改A

c++ - 在同一个赋值表达式中使用 std::move(object) 和 object.method() 。

下面表达式的结果是否定义明确?这是什么?hash_map[object.key()]=std::move(object);我不确定std::move部分的效果是否会发生在object.key()部分之前或之后,因此我的问题。 最佳答案 它的定义很明确,因为这段代码中的第一个并不重要:您可以将其重写为以下等价物hash_map[object.key()]=static_cast(object);关于代码我们能说些什么:object.key()应该在分配给map之前执行std::move(object)应在分配给map之前执行然后将对m

C++ map<char, static method pointer>?

这个问题在这里已经有了答案:Howtocreateclassobjectsdynamically?(3个答案)关闭7年前。我已经编写了一个非常基本的表达式解析器,我希望它是可扩展的,以便它可以解析用户定义的表达式类型。例如,如果在解析时遇到字符,我想创建一个用于解析以此字符开头的表达式的类的实例。我有两个问题:如何将字符关联到静态方法指针?我想使用一个静态方法来返回类的一个新实例,因为我无法获得指向类构造函数的指针。以下语法可能是错误的,但这就是想法:typedefstaticIValue*(*returnPtrIValue)();map...假设我有A类,B类扩展了A类,我可以初始化

c++ - G++ 4.4.7 中的 "names the constructor, not the type"

我有以下简单的C++代码:#includeclassA{public:A(inty):x(y){}A&operator=(constA&rhs);intx;};A::A&A::operator=(constA&rhs){this->x=rhs.x;return*this;}intmain(int,char**){Aa1(5);Aa2(4);printf("a2.x==%d\n",a2.x);a2=a1;printf("a2.x==%d\n",a2.x);return0;}第11行,A的operator=()函数的定义所在,格式不正确......或者,至少,我相信是这样。正如预期的那样,

c++ - "pure virtual method called"实现 boost::thread 包装器接口(interface)时

我有一个小包装器,它集中了与线程相关的内容:classThread{protected:boost::thread*m_thread;virtualvoidwork()=0;voiddo_work(){work();}public:Thread():m_thread(NULL){}virtual~Thread(){catch_up();deletem_thread;}inlinevoidcatch_up(){if(m_thread!=NULL){m_thread->join();}}voidrun(){m_thread=newboost::thread(boost::bind(&Thr

c++ - CRTP + 特征类 : "no type named..."

我尝试使用模板化类实现CRTP,但在使用以下示例代码时出现错误:#includetemplateclassTraits{public:typedeftypenameT::typetype;//'staticconstunsignedintm_const=T::m_const;staticconstunsignedintn_const=T::n_const;staticconstunsignedintsize_const=T::m_const*T::n_const;};templateclassCrtp{public:typedeftypenameTraits::typecrtp_typ