g ++ is the right to complain, and Microsoft has it wrong. The problem with this code is that the checkPointIn function takes a second parameter by reference, which means that it must be set to lvalue (for example, a variable or dereferenced pointer). However, the code in checkPointInside runs in a temporary object, which is an rvalue. For historical reasons, the Microsoft compiler allows this, although it is explicitly prohibited by the specification. Usually, if you run the warning level in the Microsoft compiler, it will really erroneously consider this code to be erroneous.
To fix this, either checkPointIn will take its last argument by value, or by reference to const. The latter is probably the best choice, since const links can link to rvalues, if necessary, and avoid making expensive copies in other cases.
source share