“。不能出现在常量表达式中 [英] `.' cannot appear in a constant-expression
本文介绍了“。不能出现在常量表达式中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到以下错误:
`。'不能出现在常量表达式中
(第4行):
bool Covers(const Region< C,V,D>& other)const {
const Region& me = * this;
for(unsigned d = 0; dif(me [d] .min> other [d] .min || me [d] .max< other [d] .max){
return false;
}
}
任何人都可以解释问题吗?
EDIT:
Region的定义是:
模板< typename C,typename V,unsigned D>
class Region:public boost :: array< Detail :: Range< C>,D> $
解决方案p>试试你的代码告诉我,编译器有一个问题与
me [d] .max<其他[d] .max
部分。所以点的问题是假的。相反,编译器具有比较运算符的问题。只是恢复比较使得编译器错误神奇地消失:if(me [i] .min> other [i]。 min || other [i] .max> me [i] .max){
return false;
}
I'm getting the following error:
`.' cannot appear in a constant-expression
for this function (line 4):
bool Covers(const Region<C,V,D>& other) const { const Region& me = *this; for (unsigned d = 0; d < D; d++) { if (me[d].min > other[d].min || me[d].max < other[d].max) { return false; } }
can anyone explain the problem please?
EDIT:
the definition of Region is:
template <typename C, typename V, unsigned D> class Region : public boost::array<Detail::Range<C>,D>
when
Range
has amin
andmax
variables.解决方案Trying out your code tells me, that the compiler has a problem with the
me[d].max < other[d].max
part. So the problem with the dot was bogus. Instead the compiler has a problem with the comparison operator. Just reverting the comparison made the compiler error magically disappear:if (me[i].min > other[i].min || other[i].max > me[i].max) { return false; }
这篇关于“。不能出现在常量表达式中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文