I\'m getting the following error:
`.\' cannot appear in a constant-expression
for this function (line 4):
bool Covers(const
If stakx's answer is not sufficient, you may want to look into "min" and "max" variables. There may be some preprocessor definition, preventing the whole thing from working.
Try adding
#undef min
#undef max
just before your code, to see if the error stands.
This is probably failing because you have not defined operator[](unsigned)const. I would also suggest that you use std::size_t
or int
as your loop variable; it is very uncommon to just see unsigned
. Since you are using an unsigned type, though, the logical choice would be to use std::size_t
. You could also try invoking this->operator[](d) instead of me[d] just as a sanity-check, although what you have should work fine assuming that your class implements the appropriate operator overload.
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;
}
I assume this fails because the []
operator is not a valid operation on your variables me
, other
, etc.
Did you overload the []
operator on your Region<>
class? If so, does it return an object which actually has these min
and max
members? — Does the overloaded operator return an object, an object by reference, or a pointer to an object? (In the last case, you'd need to replace .
by ->
.)
If you haven't overloaded []
, then me
, other
etc. would have to be declared as an array for your code to be valid.