提问人:YAKOVM 提问时间:9/21/2023 最后编辑:Vlad from MoscowYAKOVM 更新时间:9/21/2023 访问量:55
将类型“type”绑定到类型“const type”的值的引用会删除“const”限定符
binding reference of type 'type' to value of type 'const type' drops 'const' qualifier
问:
此问题看起来像已知的问题。但我在类型上没有任何常量。 我错过了什么? 我有以下代码:
class PlanForBlock
{
public:
void registerExtraIterator(DummyLoadIterator *ExtraIterator, const SIImpl *SInfo, Iterator2AGUAssignmentAnalisisVMP7& Iterator2AGUAnalisis) {
assert(ExtraIterator && "Not an EyeQVMPDummyLoadIterator!");
ExtraIterators.push_back(ExtraIterator);
if (SInfo->hasEyeQVMP7()) {
bool IsGenXYIt = ExtraIterator->containsDummyIterKind(GenXY);
Iterator2AGUAnalisisVMP7.addIterator(ExtraIterator, SBNonMasked,
IsGenXYIt);
}
}
};
class OtherClass
{
private:
Iterator2AGUAssignmentAnalisis Iterator2AGUAssignAnalisis;
public:
DummyLoadIterator *
generateAndRegisterDummyLoad(AGUPlanForBlock &PlanForBlock,
DummyLoadIteratorKind Kind) const;
}
DummyLoadIterator *OtherClass::generateAndRegisterDummyLoad(
PlanForBlock &PForBlock, DummyLoadIteratorKind Kind) const {
auto *Iter = initDummyLoad(PlanForBlock.getBlock(), {}, Kind);
PBlock.registerExtraIterator(Iter, SInfo, Iterator2AGUAssignAnalisisVMP7);
return Iter;
}
错误
error: binding reference of type 'Iterator2AGUAssignmentAnalisis' to value of type 'const Iterator2AGUAssignmentAnalisisVMP7' drops 'const' qualifier
PForBlock.registerExtraIterator(Iter, SInfo, Iterator2AGUAssignAnalisis);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
File.h:498:135: note: passing argument to parameter 'Iterator2AGUAnalisisVMP7' here
void registerExtraIterator(DummyLoadIterator *ExtraIterator, const SIImpl *SInfo, Iterator2AGUAssignmentAnalisis& Iterator2AGUAnalisis)
答:
0赞
Vlad from Moscow
9/21/2023
#1
目前尚不清楚变量的声明位置。我怀疑是数据成员。Iterator2AGUAssignAnalisisVMP7
Iterator2AGUAssignAnalisis
class OtherClass
{
private:
Iterator2AGUAssignmentAnalisis Iterator2AGUAssignAnalisis;
//...
但无论如何,功能generateAndRegisterDummyLoad
DummyLoadIterator *
generateAndRegisterDummyLoad(AGUPlanForBlock &PlanForBlock,
DummyLoadIteratorKind Kind) const;
是一个常量成员函数。所以争论是一个常数。因此,在此调用中,常量变量可能不会与非常量引用绑定Iterator2AGUAssignAnalisisVMP7
PBlock.registerExtraIterator(Iter, SInfo, Iterator2AGUAssignAnalisisVMP7);
上一个:返回对多态对象的引用
评论
const
generateAndRegisterDummyLoad
const
PascalCase
对于所有内容和长名称,没有指示或成员变量的特殊命名使我很难阅读。