This doesn't make any sense. The const-ness of *this* is the logical and obvious reason why methods overload on const. *this* is just as good an valid parameter as everything other ones despite the fact, that its hidden. The signature of two functions differ between *this* parameter has different types. There we go: sensible overloading and const never refers to the function itself. The fact, that it does currently is a big bug, IMO.
On Sun, Feb 19, 2012 at 1:18 AM, Timon Gehr <timon.g...@gmx.ch> wrote: > On 02/18/2012 10:06 PM, deadalnix wrote: >> >> Le 18/02/2012 16:04, Timon Gehr a écrit : >>> >>> For them, it is certainly safe. It is questionable how large the >>> effective benefit is for const, since the const qualifier would be >>> inherited for the method only, but not for its parameters. >>> >> >> The const qualifier does NEVER qualify a function. This is a >> misconception. > > > I don't care whether or not it is a misconception. It is how the language is > defined. If you want to change this, file an enhancement request. > > >> In what we call const function, what is const is the >> hhidden parameter "this", not the function. > > > Both are const. Ask the compiler. > > struct S{ > void foo()const{ > static assert(is(typeof(this)==const)); > static assert(is(typeof(foo)==const)); > } > } > > In fact, the incident that the method is const is what enables contravariant > overriding of mutable/immutable by const methods. (This is not supported for > the explicit formal parameter types.) -- Bye, Gor Gyolchanyan.