On 08/26/2016 10:09 PM, Patrick Schluter wrote:
Yes. The optimisation of removing the second call is only possible if
there is no access using the this pointer. The call to setN() (or any
member function using the mutable this pointer), will mandate the
compiler to call getN() again.

If setN is called or not does not affect getN's purity, though. You wrote that (the method) getN is not pure and should be rejected by the compiler, but both variants (method and function) are equally pure or impure.

Reply via email to